Can I use the GC to find the number and type of each java object?
Jeff Sturm
jsturm@one-point.com
Mon May 10 20:06:00 GMT 2004
On 2004年5月10日, David Daney wrote:
> I occasionally run out of memory when running GCJ compiled code, and in
> the interests of understanding what is happening, I would like to be
> able to dump the type, size and occurrence count of each reachable object.
>> It there a predefined method, or lacking that a good place to hook in to
> boehm-gc to find information about all reachable objects?
GC_print_block_list() does some of this, though it knows little about java
objects. You can call it from within gdb.
Output looks like:
(kind(0=ptrfree,1=normal,2=unc.,3=stubborn):size_in_bytes, #_marks_set)
(0:56,73)(0:56,73)(0:56,73)(4:24,170)(0:56,73)(0:56,73)(4:24,170)(0:56,73)
...
blocks = 2133, bytes = 9154560
Java objects have either kind 0 ("pointer-free", strings and primitive
arrays) or 4-6 (most objects). Each block contains objects of one size
only. The "#_marks_set" field gives you an idea how many objects in a
block are reachable (I think this number is accurate only after a
collection).
Hans will probably correct me if I got any of that wrong :-)
Jeff
More information about the Java
mailing list