Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to measure peak heap memory usage in Java?

How to measure peak heap memory usage in Java? MemoryPoolMXBean keeps track of the peak usage per memory pool, but not the entire heap. And the peak heap usage is not simply the sum of different heap memory pools.

like image 357
Pinch Avatar asked Sep 26 '22 18:09

Pinch


1 Answers

Did you think about using totalMemory() function from Runtime class - docs? Also there are some free tools like VisualVM or JStat, example:

jstat -gc <pid> <time> <amount>

Hope that helps.

like image 69
m.aibin Avatar answered Sep 28 '22 06:09

m.aibin