stackoverflow
stackoverflow

Reputation: 137

How to get maximum memory used by java program

Is there a way to get the peak memory used at any given point during a java program run? So far I've only seen solutions that give total memory consumed.

Upvotes: 1

Views: 336

Answers (1)

Vitalii
Vitalii

Reputation: 481

You can try this JDK tools for heap analyzis:

  • VisualVM
  • jstat (console tool)

RSS mem usage can be found on unix by comman line tools ps or top, or by JDK tool:

  • jcmd <pid> VM.native_memory detail.diff (java process should be run with -XX:NativeMemoryTracking=summary JAVA_OPTS)

RSS Peak usage can be found on linux in /proc/<pid>/status file in VmHWM field (man).

Upvotes: 6

Related Questions