When I open a memory snapshot via the YourKit Java Profiler GUI, I can see the cumulative "shallow size" for all objects that are strong reachable via a GC root.
For example, I might see:
... where "93 MB" is the cumulative "shallow size" for all objects that are strong reachable via a GC root.Objects: 7,935,461 / shallow size: 782 MB / retained size: 782 MB Strong reachable among them: 2,090,931 (26%) / shallow size 93 MB (11%) / retained size: 233 MB (29%)
Is it possible to get this same number -- the "93 MB" number from the example above -- from a memory snapshot programmatically, via the com.yourkit.api.MemorySnapshot (or some other) API? I believe the MemorySnapshot.getShallowSize() method uses XML query syntax like the examples on the "set description language" page (https://www.yourkit.com/docs/java/help/language.jsp). I haven't found anything on that page, though, which mentions anything specific about filtering the list of objects selected to only those which are reachable from GC roots via strong references, like what is shown in the Profiler GUI.
A query like "<objects class=\"*\">" would seem to just give all available objects. A query like "<retained-objects><roots/></retained-objects>" appears to consider the cumulative set of objects that are reachable from GC roots but this also appears to include objects that aren't included in the "strong reachable" filter that the GUI provides.
Thanks much for any pointers / advice you might be able to provide!