jvisualVM 分析heapdump

时间:2022-10-08 21:05:48

代码很简单,eclipse里面设置下最大堆空间为128m,:

jvisualVM 分析heapdump

@Test
public void testOutOfMemory() {
List<NewsAddDto> documents = new ArrayList<>();
  while (true) {
    NewsAddDto d = new NewsAddDto();
    documents.add(d);
  }

}

"Attach Listener" daemon prio=5 tid=5 RUNNABLE

"Finalizer" daemon prio=8 tid=3 WAITING
at java.lang.Object.wait(Native Method)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
Local Variable: java.lang.ref.ReferenceQueue#1
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)
Local Variable: java.lang.System$2#1

"Signal Dispatcher" daemon prio=9 tid=4 RUNNABLE

"Reference Handler" daemon prio=10 tid=2 WAITING
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)

"ReaderThread" prio=5 tid=9 RUNNABLE (堆转储时时,正在)
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
Local Variable: java.io.FileDescriptor#1
at java.net.SocketInputStream.read(SocketInputStream.java:122)
Local Variable: byte[]#1
Local Variable: java.net.SocketInputStream#1
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
Local Variable: java.nio.HeapCharBuffer#1
Local Variable: java.nio.charset.CoderResult#2
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
Local Variable: sun.nio.cs.StreamDecoder#1
at java.io.InputStreamReader.read(InputStreamReader.java:184)
Local Variable: char[]#10
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
Local Variable: java.io.InputStreamReader#1
at java.io.BufferedReader.readLine(BufferedReader.java:382)
Local Variable: java.io.BufferedReader#1
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner$ReaderThread.run(RemoteTestRunner.java:135)

"main" prio=5 tid=1 RUNNABLE
at java.lang.OutOfMemoryError.<init>(OutOfMemoryError.java:48)
at news.TestNewsCollection.testOutOfMemory(TestNewsCollection.java:83)
Local Variable: java.util.ArrayList#12
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Local Variable: sun.reflect.NativeMethodAccessorImpl#1
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
Local Variable: java.lang.reflect.Method#4
Local Variable: sun.reflect.DelegatingMethodAccessorImpl#1
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
Local Variable: org.junit.runners.model.FrameworkMethod$1#1
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
Local Variable: news.TestNewsCollection#1
Local Variable: java.lang.Object[]#13
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
Local Variable: org.junit.internal.runners.statements.InvokeMethod#1
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
Local Variable: java.util.ArrayList$Itr#1
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
Local Variable: org.junit.internal.runners.statements.RunBefores#1
Local Variable: org.junit.internal.runners.model.EachTestNotifier#1
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
Local Variable: org.junit.runner.Description#2
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
Local Variable: org.junit.runners.ParentRunner$1#1
Local Variable: org.junit.runners.ParentRunner$3#1
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
Local Variable: org.junit.runners.model.FrameworkMethod#1
Local Variable: java.util.ArrayList$Itr#2
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
Local Variable: org.junit.runners.ParentRunner$2#1
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
Local Variable: java.util.ArrayList$Itr#3
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
Local Variable: org.junit.runners.BlockJUnit4ClassRunner#1
Local Variable: org.junit.internal.runners.statements.RunBefores#2
Local Variable: org.junit.internal.runners.model.EachTestNotifier#2
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
Local Variable: org.junit.runner.notification.RunNotifier#1
Local Variable: org.junit.runner.Result#1
Local Variable: org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference#1
Local Variable: org.junit.runner.Result$Listener#1
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
Local Variable: java.lang.String#21
Local Variable: java.lang.String[]#2
Local Variable: org.eclipse.jdt.internal.junit.runner.ITestReference[]#1
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
Local Variable: org.eclipse.jdt.internal.junit.runner.TestExecution#1
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
Local Variable: org.eclipse.jdt.internal.junit.runner.FirstRunExecutionListener#1
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Local Variable: java.lang.String[]#3
Local Variable: org.eclipse.jdt.internal.junit.runner.RemoteTestRunner#1