Browse Source

oomtest

pull/1/head
马府强 2 years ago
parent
commit
e418b36dbd
  1. 8
      oomdemo/.idea/.gitignore
  2. 13
      oomdemo/.idea/compiler.xml
  3. 20
      oomdemo/.idea/jarRepositories.xml
  4. 14
      oomdemo/.idea/misc.xml
  5. 2
      oomdemo/oomdemo.iml
  6. 12
      oomdemo/pom.xml
  7. 29
      oomdemo/src/main/java/com/woniu/OOMTest.java
  8. BIN
      oomdemo/target/classes/com/woniu/OOMTest.class

8
oomdemo/.idea/.gitignore

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../:\java project\oomdemo\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

13
oomdemo/.idea/compiler.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="oomdemo" />
</profile>
</annotationProcessing>
</component>
</project>

20
oomdemo/.idea/jarRepositories.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

14
oomdemo/.idea/misc.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

2
oomdemo/oomdemo.iml

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />

12
oomdemo/pom.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.woniu</groupId>
<artifactId>oomdemo</artifactId>
<version>1.0-SNAPSHOT</version>
</project>

29
oomdemo/src/main/java/com/woniu/OOMTest.java

@ -0,0 +1,29 @@
package com.woniu;
import java.util.ArrayList;
import java.util.List;
/**
* 内存溢出的参数
* Eclipse Memory Analyzer分析内存溢出
* -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\woniu
*
*1.占用内存过大的对象有哪些 Histogram
*2.被谁引用的 dominator_tree
*3.定位到具体的代码 thread_overview
*
* 排查的过程都很简单难的是如何解决如果代码是自己写的那一会就改完了
* 如果是一些中间件的代码造成的内存溢出就要求你对中间件的实现有个基本的了解才能解决
*/
public class OOMTest {
public static void main(String[] args) {
List<byte[]> memoryLeakArray = new ArrayList<byte[]>();
for (int i = 0; i < 1024; i++) {
byte[] tmp = new byte[1024 * 1024]; // 添加1M的数据到List中
memoryLeakArray.add(tmp); //warning: 这里会造成OOM
}
}
}

BIN
oomdemo/target/classes/com/woniu/OOMTest.class

Binary file not shown.
Loading…
Cancel
Save