This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Debugging memory leaks
- From: Hans Boehm <Hans dot Boehm at hp dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: "Boehm, Hans" <hans dot boehm at hp dot com>, java at gcc dot gnu dot org
- Date: Sun, 17 Apr 2005 11:28:13 -0700 (PDT)
- Subject: Re: Debugging memory leaks
- References: <16991.58252.664506.704480@cuddles.cambridge.redhat.com>
Unfortunately, you currently have to rebuild libgcj to get this
functionality. You need to build with --enable-gc-debug.
If you are debugging an application that can be made to leak most of
the memory in its heap, you can usually get the information you want by
setting the GC_BACKTRACES environment variable to a small integer. This
will print the indicated number of backtraces from random addresses at
each pc.
If you need something more specific, look at gc_backptr.h. You should be
able to use this directly from a debugger. But watch out for unintended
reflection: It's easy for this stuff to accidentally find "pointers" from
your debugging code itself.
Hans
On Fri, 15 Apr 2005, Andrew Haley wrote:
> I've been having a great deal of difficulty tracking down memory leaks
> in libgcj.
>
> What I need is some sort of interface that allows me to enquire who
> points to an object. The ideal interface would be something like
> points_to (obj) -> obj. I realize that in practice there is a set of
> objects that point to a particular object, but that doesn't concern
> me: one is all I need.
>
> Is there any interface within the GC that can give me this function?
> If not, how hard would it be to provide? Can you provide me with some
> guidance?
>
> Ideally, I'd love to have something like Glasgow Haskell Compiler's
> heap profiling, but I'll settle for much less.
>
> Thanks,
> Andrew.
>