How to use jstat to monitor heap memory in the JVM?
To view the heap memory usage in JVM, you can use the jstat command. Here are the specific steps:
- Open the command line tool and navigate to the bin directory of the JVM, which is typically located in the installation directory of the JDK.
- Enter the following command to check the current heap memory usage of the JVM process:
jstat -gc <pid>
The process number for the JVM process can be obtained using the jps command. Running this command will display the current JVM process’s heap memory usage, including the usage of parts such as Eden, Survivor, and the old generation.
- If you need to see more detailed heap memory information, you can use the following command:
jstat -gccapacity <pid>
This command can display detailed information such as capacity, used space, and peak space of each memory heap region.
By following the above steps, you can now use jstat in the JVM to monitor the usage of heap memory.