Finding memory leaks with YourKit
Memory Leak
Memory Tab
Heap: storage of java objects
Non heap : to store loaded classes and other metadata
Class list : It is telemetry of memory consumed.
In the heap memory we can see the changed in memory usage with light pink,light blue coloe
Now force GC to GC.
We can see the memory usage drops, it may not return to its previous value.
This says there is memory leakage
______________________________________________
Memory snapshot
Take the sanpshot and open the window
class list has all the list of classes used.
claculate the class with biggest retained size by calculating
Now go to Biggest objects
From the biggest object click on Path from GC Roots
Click to Start Calculation in the bottom tab
We can right click on the object having highest retained size.
We can select the object s of the class having hifhest retained size. We can
evaluate the field consuming more data.
We should keep removing the objects if it is there.
_______________________________________________________
Anothe way
generations
It gives the variable names as well. so it is good practice to use
the IDE along with the code.
_________________________________________________________________
CPU Profiling
1. Start the cpu sampleing
2. Save the snapshot
3. Open the snapshot
4. See the class loading on all the threads
5. Open the hotspots
6. Check from where this method is been called
Memory Leak
Memory Tab
Heap: storage of java objects
Non heap : to store loaded classes and other metadata
Class list : It is telemetry of memory consumed.
In the heap memory we can see the changed in memory usage with light pink,light blue coloe
Now force GC to GC.
We can see the memory usage drops, it may not return to its previous value.
This says there is memory leakage
______________________________________________
Memory snapshot
Take the sanpshot and open the window
class list has all the list of classes used.
claculate the class with biggest retained size by calculating
Now go to Biggest objects
From the biggest object click on Path from GC Roots
Click to Start Calculation in the bottom tab
We can right click on the object having highest retained size.
We can select the object s of the class having hifhest retained size. We can
evaluate the field consuming more data.
We should keep removing the objects if it is there.
_______________________________________________________
Anothe way
generations
It gives the variable names as well. so it is good practice to use
the IDE along with the code.
_________________________________________________________________
CPU Profiling
1. Start the cpu sampleing
2. Save the snapshot
3. Open the snapshot
4. See the class loading on all the threads
5. Open the hotspots
6. Check from where this method is been called
No comments:
Post a Comment