OutOfMemory Exception - how does VisualVM help locate a memory leak using the heapdump file?

I tested my webapp locally on my computer and controlled it using VisualVM. Recently, I also started using JMeter, as it was suggested to perform some load tests, as I suspected that I had a slow memory leak somewhere.

Today, my webapp finally OutOfMemory exception. I had the HeapDumpOnOutOfMemoryError and HeapDumpPath parameters if this happened. Heap dump file created.

I opened this file (java_pid2760.hprof) in VisualVM, and frankly, I don’t understand how I should be able to identify the culprit of this memory leak ...

How do you use VisualVM to analyze the heap dump and find the class / instance that generates the memory leak?

+4
source share
2 answers

Using VisualVM to analyze heap dumps and pin-point memory leaks is not easy, and I would not recommend using this tool if you are working on this type of problem for the first time. Consider downloading HPjmeter and letting it do the job.

After opening the dump file, select the option "Edited reference chart". This will show you all the objects in your webapp, sorted by size. In most memory leak scenarios, you infiltrate one type of objects that stack balloons over time in a heap. HPjmeter helps you quickly identify this case.

+1
source

Source: https://habr.com/ru/post/1338748/


All Articles