Spring Framework How to find CPU and Memory used by Java process in Solaris – prstat command example

We often need to find CPU and memory utilization of a particular Java process in order to get some performance stats, capacity planning or just to understand the current load on system. Performance monitoring and testing is integral part of any Java application development, especially if you are working in high frequency trading space. In order to fix a performance problem, you have to find them first and knowledge of right tools and commands helps there. One of the primary cause of poor application performance be it Java or any other process is exhaustion of important resources like CPU and memory. Monitoring CPU and memory utilization of your Java process gives you some useful insight like what is normal memory and CPU utilization, when are you getting spikes on CPU and memory consumption. If  heap memory is constantly increasing over time than it’s an indication that your Java application may have a memory leak. In this Java performance tutorial, we will learn about two most common Solaris commands prstat and pmap to find CPU and memory utilization of Java process. prstat is a process monitoring tool easily available in any Solaris systems including SPARC and x86 boxes, which provides useful statics of CPU and memory utilization of a process. For other systems e.g. windows you can use windows task manager for CPU monitoring and Linux you can use top command for same purpose. By the way, you can also check out Java performance by Charlie Hunt and BinuJohn, it is immensely helpful for Java performance monitoring and tuning. This is the book, which gives you right kind of tools and knowledge required to find performance stats for Java application.
Read more »