Rate This Document
Findability
Accuracy
Completeness
Readability

Tuning Result

Optimizing the Program

After locating the memory leak points through real-time profiling and sampling profiling, we can view the specific service codes based on the provided class, instance, and reference chain information, and then analyze the code optimization strategy accordingly.

If we consider the program in this example as a scenario where cached data is stored, we can add a periodical clearance policy.

Figure 1 Optimized code

After the optimization, we can find that the heap memory is released and GC activities are normal on the Overview page.

Figure 2 Optimized program

Summary

In this practice, memory leak points in Java programs are detected through real-time profiling and sampling profiling and then optimized for better program performance.

When tuning other programs, you need to perform tuning operations based on the analysis results collected by the Java Profiler and the corresponding tuning suggestions. For details about the tuning roadmap, see this practice.