Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get visual graph of heap memory usage in Java over a span of time

I am currently using Visual VM to monitor the heap memory usage of my Java application. However I would like to somehow see the heap memory usage over a span of time like for example a day and not just get a snapshot.I would like to be able to leave Visual VM or a tool on and let it log the memory usage and then later after one day, I can go back and see a graph of it. Is there a way to do this using Visual VM? If yes, how? If not, what tool can I used to do this?

like image 317
Jeune Avatar asked Nov 30 '10 17:11

Jeune


People also ask

How do I monitor heap usage?

The easy way to monitor Heap usage is by using a commercial APM (Application Performance management tool) such as CA Wily APM, AppDynamics, New Relic, Riverbed, etc. APM tools not only monitor the heap usage, but you can also configure the tool to Alert you when Heap usage is not normal.

How do I see Java memory usage?

Using VisualVM (jvisualvm) jvisualvm is a tool to analyse the runtime behavior of your Java application. It allows you to trace a running Java program and see its the memory and CPU consumption. You can also use it to create a memory heap dump to analyze the objects in the heap.

How do you analyze heap memory?

Eclipse Memory Analyzer Tool ( MAT ) is used for analyzing heap dump files which contain objects in memory. Each heap dump file can be thought of as a snapshot in time and details the memory occupied by specific JVM threads.


1 Answers

Run your Java program with the following Java options:

-Xloggc:log.out -XX:+PrintGCDetails -XX:+PrintGCTimeStamps

and download HPjmeter to visualize log.out.

Also see SUN's GC portal webpage for more options to run with. Since the data is written to a file, you won't have any problems collecting days or weeks worth of data. Of course, if you wish to visualize data with lots of information, you'll need to run HPjmeter with more memory.

Your other option is to use JConsole.

like image 119
Amir Afghani Avatar answered Oct 20 '22 12:10

Amir Afghani