Hi,<br><br><br>I am working on a project of visualizing the HotSpot
heap. It is basically a GCSpy rewrite and I am trying o write a HotSpot
driver. <br><br>Just very quickly what the tool is providing - set of
tiles per every heap space (young, old and permanent generation), where
every tile has a well defined size (let's say 64kB). The visualization
is then defined by the color of every tile (the white means tile is
absolutely free of objects and 100% red tile means the whole tile is
used by objects).<br>
<br><br>To do that, I need 3 information:<br><ol><li>object size - how many bytes every object consumes in memory (not recursive/deep size)<br></li><li>object
address - to compute the heap fragmentation, I need to know the address
of object (when using together with size, I should know the exact part
of heap occupied by every object)<br>
</li><li>heap spaces - what heap spaces are used and their addresses as well (to know what object belongs to what heap space)</li></ol><p><br></p><p>I
spend quite a lot of time trying to figure out how can we get those
information and there is a way to get all of them, however I need some
interactions of APIs:</p>
<ol><li>object size - can by determined by Java Agent, native agent, JVMTI and serviceability agent as well</li><li>object address - the only way I found is by using the Serviceability agent</li><li>heap spaces - again just Serviceability agent seems like having such a capability</li>
</ol><br>Now the idea is to use JVMTI and Serviceability agent together.
JVMTI will call callbacks every time object is allocated (for "new"
object allocation bytecode instrumentationwill be used), deallocated or
GC was finished and the size and address information will be determined
by Serviceability Agent. For performance reasons it will be super
inefficient to iterate through the whole heap every time JVMTI generates
callback. Well, the problem is that even if I get notifications from
JVMTI, I cannot determine the address of object from JVMTI, so I don't
know how to map the identity of object from JVMTI to Serviceability
agent.<br>
<br>So I should be able to just update the part of heap that is really
needed to be updated instead of whole heap and I have no idea how this
could be achieved.<br><br>Do you have any idea how could I get the
object address and heap spaces from JVMTI, or the callbacks (JVMTI
callbacks like objectAlloc(), GCFinished(), ...) from Serviceability
agent, or how to connect those APIs to work together?<br>
<br><br>Thanks very much,<br>Martin Skurla