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

别说谁变了你拦得住时间么 提交于 2020-01-12 03:28:17

问题


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?


回答1:


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.




回答2:


Try the Memory tab in JConsole. JConsole is also included with the Oracle JDK, like JVisualVM, so you should already have it. It has a time range of "all" which should work for what you want to do. It will look like this:



来源:https://stackoverflow.com/questions/4316649/get-visual-graph-of-heap-memory-usage-in-java-over-a-span-of-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!