Watch out for maximum memory usage in your Java profile

I am trying to detect a memeory leak in my java codes using VisualVM java profilers. I want to report maximum memory usage before and after fixing a memory leak. When starting VisualVM or other java profiles, is there anyway to find out the peak of using memeory? Thanks!

+3
source share
3 answers

You can do this with VisualVM. First, install the VisualVM-MBeans plugin and restart VisualVM. After that, on the new MBeans tab, select java.lang.Memory.HeapMemoryUsage. The maximum value will give you the maximum allocated memory.

Update

, HeapMemoryUsage.max . , java.lang.MemoryPool. <Generation> .PeakUsage.used. , , , PeakUsage.max Eden Space Old Gen plus Survivor Space .

, :

  • . , JMX.

  • , "" VisualVM, "" "", .

  • , , , , , "" VisualVM. .

+2

Runtime.maxMemory() , VM ( ). , .

0

Use jmap or -XX: + HeapDumpOnCtrlBreak to accurately measure the memory used in your application at any given time. Both of these mechanisms trigger the GC when a memory snapshot is taken, so it more accurately reflects the contents and size of the heap. You can use jhat to open a heap dump.

0
source

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


All Articles