WHAT IS PROFILING AND HOW TO CREATE ONE ?

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. 
  1. 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 . 

  1. Extract your File and open in Intellij IDE.
  2. Make changes in your application properties like server.port= 8090
  3. Create a new file ProfilingExample.java . write your program and call in main method . 
  4. Run the spring application on the line 9 of main method . 
  5. 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. 
  6. 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

Shopping cart

0
image/svg+xml

No products in the cart.

Continue Shopping