[gclist] Java Developer's Journal GC advice

Michael Hicks mwh@cs.umd.edu
06 Sep 2003 10:35:18 -0400


On Fri, 2003-09-05 at 22:39, David Chase wrote:
> > I don't view clearing of pointers as equivalent to explicit freeing:  
> > The former is type-safe, while the latter isn't.  I don't think you 
> > can avoid pointer clearing completely if you care about space usage:
> 
> This is not entirely true.  You can use typed pools to recycle objects. 

A disadvantage of typed pools is that they don't prevent dangling
pointers.  That is, while there is no danger of using an object in a
type-incorrect way (e.g. confusing an int for a pointer), you can still
prematurely free the object (return it to the pool) and then re-allocate
it to another part of the program, leading to two parts of the program
treating the same memory as if it were two different objects (albeit of
the same type).

There is recent work on type-safe approaches to the more traditional
free(), which prevent dangling pointers entirely.  This work typically
builds on a notion of linear (non-aliased) pointers.  We have recently
integrated support for manual, per-object freeing into Cyclone, and
found that it can improve the space usage and throughput of at least two
server applications, relative to the BDW GC.  The cost is that
programmers must use particular, checkable idioms, but our experience
has been that this is not too onerous.  See
http://www.cs.umd.edu/Library/TRs/CS-TR-4514/CS-TR-4514.pdf for more
details.

Mike