IntelliJ IDEA Profiler
Profiler gives an accurate information about our application performance. It measures the performance of CPU, Memory and Heap usage by our application. It also provides us the detailed information about application thread. VisualVM tool is used to measure the Java application profiling.
What is VisualVM?
It is a visual tool which has been bundled with the JDK along with Java 6 or greater version. It is good for beginners and gives detailed information about our application performance.
To install VisualVM, type the following in the terminal:
We can see here about the usage of CPU, Heap, Classes and Threads. We can also see specific usage by hovering the mouse over any graph.
Every Java application have multiple Threads. We can see the detailed information about threads in VisualVM tool. Select Thread tab, it will show various statistics about our application threads such as number of Live threads and Daemon threads . We can see it in the following figure in which Running, Sleeping, Wait, Park, Monitor thread shown us.
VisualVM gives us the information of CPU, Memory Sampling and Memory Leak. To do sampling, select application and choose Sampler tab. Sampler Tab have three Sub-Tab-: CPU Tab, Memory Tab, and Stop Tap.
To do the CPU sampling, click on CPU button. The following screenshot will appear.
To do the Memory Sampling, click on Memory button. The following screenshot will appear.
Memory leak is a situation where some objects are not used in the application anymore and garbage collector fails to recognize them as unused. During the running of program, it fills up the heap area with an object which are not used in the program. When the memory space is full because of the unnecessary object storage then we can understand it the indication of the memory leak.