Q:

How we check the past record of the usage of Memory and CPU by JVM

I want to write an admin tool for a website. In which i want to show the memory usage and CPU usage of the website in a graph. I read somewhere that JVM writes these data in a dump file which MAT tool use to show the result. So my question is where JVM dump this file and at what rate. 
Because i want to show on the graph the last 24 hour usage. So how we can capture this data.
Looking for help

A:

There's nothing at the moment inherent in the JVM that will produce the stream of data you want. You could leave a profiler such as JVisualVM hooked up to your app, but that might also slow it down considerably (that said, for memory profiling it's not so bad... depends on the non-functional requirements of your app).
Two further options:
Write your own code using MBean stuff
In a ScheduledExecutorService, run a periodic process that interrogates the JVM via the MBean interfaces. You can generate a heap dump that can be viewing in MAT.
Use cron and jmap
You can also use jmap to generate heap dumps and schedule that at the operating system level to run every once-in-a-while. This might be better if you don't want to, or can't, alter your code.

