httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <>
Subject Re: Apache 2.0/NSPR
Date Sun, 13 Sep 1998 01:44:15 GMT

On Sat, 12 Sep 1998, Alexei Kosut wrote:

> On Sat, 12 Sep 1998, Ben Hyde wrote:
> > Personally I find even the idea of adding pfree to the pool
> > abstraction distasteful.
> A prealloc would be nice, though.

If you have that, then you also have pfree().  Unless you're really
referring to

> P.S. I haven't looked at the GC that Simon mentioned, but I'm wondering
> how in the heck one can do garbage collection in C just by substituting
> malloc() calls - AFAIK, there's no way to keep track of when pointers get
> duplicated (this is why C++ garbage collecters are more effective - you
> can overload all the operators on the pointer), so reference counting is
> impossible. And since pointers look like any other integer in memory
> there's no way to identify them. Is there something I'm missing?

If you allow the full generality of C, no.  But with restrictions (that
pretty much all programs satisfy) there's a scavenging technique that
works fairly well.

Consider all of the stack, plus the registers, plus the _data, and _bss
sections as a collection of potential pointers.  You can ignore any of the
words which don't point into the heap.  The rest are possibly live
pointers to allocated data.  Mark all the blocks as allocated, and add
their words to the collection of potential pointers.  Repeat until you've
exhausted all the potential pointers.  Everything that's left unmarked is


View raw message