This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: status of gcj's boehm collector?
- From: "Boehm, Hans" <hans_boehm at hp dot com>
- To: "'Andrew Haley'" <aph at cambridge dot redhat dot com>, "Boehm, Hans" <hans_boehm at hp dot com>
- Cc: "'Adam Megacz'" <gcj at lists dot megacz dot com>, java at gcc dot gnu dot org
- Date: Thu, 6 Dec 2001 13:52:42 -0800
- Subject: RE: status of gcj's boehm collector?
Interesting. Unfortunately, I think the standard Java interface isn't quite
sufficient to do that right. I think the logic to do this properly is:
if (I'm out of file descriptors and need one, but not before) {
for (;;) {
System.gc();
System.runFinalization();
if (the preceding call ran no finalizers || file descriptor is
available) break;
}
}
The loop is needed because running finalizers may result in dropping more
objects. If finalization dependencies are correctly enforced (in Java the
client code needs to do that), that's even reasonably likely. I think this
mean you really need runFinalization to return an indication of whether or
not it did anything so that you can avoid a potentially infinite loop here.
In most cases running the loop a maximum of N times, for some small N, is
probably good enough.
Hans
> -----Original Message-----
> From: Andrew Haley [mailto:aph@cambridge.redhat.com]
> Sent: Thursday, December 06, 2001 10:49 AM
> To: Boehm, Hans
> Cc: 'Adam Megacz'; java@gcc.gnu.org
> Subject: RE: status of gcj's boehm collector?
>
>
> Boehm, Hans writes:
> >
> > Thinking about this some more, I think the current System.gc() call
> > actually makes a little bit of sense if you run out of some
> > non-memory resource, and want to run both the collector and
> > finalizers.
>
> Like file descriptors, f'rexample.
>
> We depend on system.gc closing unused file descriptors. I suspect
> we'd run out of those long before running out of memory in some
> applications.
>
> Andrew.
>