This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can I use the GC to find the number and type of each java object?


On Mon, 10 May 2004, 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]