Profiling is the process of analyzing a java application’s performance, memory usage , cpu consumption, thread execution and other runtime behaviours to identify bottlenecks and optimize efficiency.
- Why is Profiling Important ?
- Detects Memory Leaks.
- Identifies High CPU usage areas.
- Finds slow methods affecting performances.
- Optimizes GC(Garbage Collections).
- Helps in Thread Performance analysis (Detecting DeadLock , Race conditions).
- Types of Profiling
- CPU Profiling – Measures Method execution time to find slow methods.
- Memory Profiling – Track memory allocation and detects memory leaks.
- Thread Profiling – Monitor thread states , deadlocks and connections.
- Garbage Collections Profiling – How often GC runs and its impact on performances.
- How to Run Profile in Java applications.
Create a java project using spring Initializr .
Using Maven and JDK 17 add dependency Spring Web .with JAR file
Click on Generate .
- Extract your File and open in Intellij IDE.
- Make changes in your application properties like server.port= 8090
- Create a new file ProfilingExample.java . write your program and call in main method .
- Run the spring application on the line 9 of main method .
- Before it go to https://visualvm.github.io/download.html this site and download the java visualvm and extract it . go to the bin folder of visualvm.
- Run the Application by double click on it.
Now open the visualvm and you will find your application is running with a PID (process ID) . and now you can explore it visually.
SAMPLE OUTPUT OF PROGRAM ;

SAMPLE JAVA VISUALVM

