Hello,
I am about to do some memory distribution analysis of the content of a java heap. In a first step I build an JVMTI agent which writes all reachable objects with their size to a file. For each reference caught by
IterateOverReachableObjects()
I write refererer and referee to another file too.
First the sum of
all object sizes is is around 130 % of the heap size reported by
jstat
and
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()
Both report exactly the same.
Taking the sum of all objects only found as referees is the references-file is little smaller, but none the less significantly larger than reported by the two named possibilities.
Whats the reason for this? What is wrong on my approach? Is it what the JVMTI reference says? That :
"... This size is an implementation-specific approximation of the amount of storage consumed by this object. It may include some or all of the object's overhead, and thus is useful for comparison within an implementation but not between implementations. The estimate may change during a single invocation of the JVM."
Robert