Search code examples
eclipseeclipse-pluginprofilingprofilerjprofiler

Track objects created from my own classes


I have an application which extends the eclipse product. Letting it run overtime, the RAM usage increases to the maximum heap space.

The application does no action, it's just staying in background. I ran JProfiler, then in the Live Memory section I marked the current objects by pressing the Mark current button. Looking at the Difference column, there are hundreds of objects being created (char, HashMap, LinkedHashSet etc).

Is there a feature in JProfiler which allows me to see if the objects were allocated from one of my classes (e.g. objects of type A allocated from classes with the pattern com.example.mypackage.*)?

This would be helpful to see if I caused the memory leak or if I must fill a bug report to someone else.

I am open to any other profiler suggestion which provides such a feature.


Solution

  • In JProfiler, Allocation recording is intended for exactly this purpose. First of all, make sure that the call tree filters in the session settings just include your own packages.

    Then go to "Live Memory->Allocation Call Tree" and record allocations. In the call tree you can see the cumulated call stacks with information about allocations. Invoke "View->Analyze->Show classes" from the main menu to show the specific allocated classes for each node. You can also select a particular class or package and show the allocation tree selectively.

    There is an associated "Allocation hot spots" view that shows you the call stacks with most allocations. If you just want to see your own classes, select "Add to calling class" in the "Hot spot options" chooser in the top right corner.