Reputation: 12363
I've coded a java program that I can run using its resulting jar
java -jar foo.jar
I'm interested in obtaining the maximum memory size that my jar program request during its execution. Actually to do that I just look the memory management (like htop
), but its not accurate.
I wonder if there is a special parameter that one set while launching the jar that allow to obtain such information at the end of the execution ?
Upvotes: 2
Views: 2854
Reputation: 8657
Have you tried visualVM
, its free and powerful tool to track the java performance application, it'll show you how much your JVM committed from the physical memory, also the total memory of the application that the current JVM running, and some features:
Its come with the JDK package, so you don't have to install it, for more info check this
In your case you can do the following :
java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=8484 -Dcom.sun.management.jmxremote.ssl=false -jar foo.jar
Open the visualVM
,then select File -> Add JMX connection
, then type your host ip and the port that you have been specified in the parameters "in our case its 8484" separated by :, eg localhost:8484
, then you ready to go.
Upvotes: 4