I'd like to examine a snapshot via API, walking around on call tree vs allocations. There's a view to do this in the UI, if you look at Memory + Class and Package + Allocations tabs.
I have the MemorySnapshot API working well on my snapshots, including using set description language to query known class trees. It's clear that you can use getShallowSize() and getObjectCount() to answer a specific question about what memory is linked where. But it's not clear how to use MemorySnapshot to examine which call path has performed an allocation, only where the memory sits after it got created.
What am I missing? Is there more example material reading snapshots than sample 2 in the distribution?
API to walk allocation tree?
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: API to walk allocation tree?
There is no API for that, please use the profiler UI to find where particular objects were allocated. Also I can suggest to consider the "Export with command line tool" functionality to get object allocation statistics:
https://www.yourkit.com/docs/java/help/export.jsp
Anyway, the API is intended to perform tasks automatically, on regular basis. What is your task? What kind of analysis would you perform?
https://www.yourkit.com/docs/java/help/export.jsp
Anyway, the API is intended to perform tasks automatically, on regular basis. What is your task? What kind of analysis would you perform?
-
- Posts: 2
- Joined: Mon Aug 03, 2015 4:55 pm
Re: API to walk allocation tree?
Okay, I'll play some more with the command line exporter.
My task is roughly: "which objects were allocated from which call stacks?" The objects are not among the retained size from those call stacks; they're side effects and get stored in other pools.
So I kind of expected an iterator of some kind to walk around in the snapshot, which would look a lot like getShallowSize() or getObjectCount(). It would take a selection XML like those and for each element, hand you some kind of tuple roughly.
A user's traversal could then examine every object in the snapshot via reflection, which you can't do now. You can only count them and size them, but you have to provide each name of each thing one at a time.
My task is roughly: "which objects were allocated from which call stacks?" The objects are not among the retained size from those call stacks; they're side effects and get stored in other pools.
So I kind of expected an iterator of some kind to walk around in the snapshot, which would look a lot like getShallowSize() or getObjectCount(). It would take a selection XML like those and for each element, hand you some kind of tuple roughly
Code: Select all
{ String full_object_class, List<String> allocation_call_stack, long size, etc }
A user's traversal could then examine every object in the snapshot via reflection, which you can't do now. You can only count them and size them, but you have to provide each name of each thing one at a time.
-
- Posts: 6172
- Joined: Wed Aug 11, 2004 8:37 am
Re: API to walk allocation tree?
Please note that the profiler UI provides a powerful set of views to comprehensively solve this task:My task is roughly: "which objects were allocated from which call stacks?" The objects are not among the retained size from those call stacks; they're side effects and get stored in other pools.
https://www.yourkit.com/docs/java/help/ ... _alloc.jsp