Boost logo

Boost :

Subject: Re: [boost] request for interest in a garbage collection library
From: jbosboom_at_[hidden]
Date: 2009-04-20 13:56:07


> If objects like files and mutexes are dynamically allocated, then they
> are deleted at some point, aren't they? so, if the programmer wants to
> add garbage collection to these objects, so he/she doesn't have to
> manually track memory, he/she can replace the delete operations with
> RAII and let the GC handle the memory part.

The point of garbage collection is that the programmer does not need to
manually free resources by deleting. However, non-memory resources need
to be freed deterministically, so garbage collection is not a good
solution.

So simply don't use it for that. The obvious solution is to continue
managing the lifetime of objects representing or holding non-memory
resources manually, either by allocating them with automatic duration or
holding them by a reference-counted pointer. Just because garbage
collection is there doesn't mean you have to use it exclusively. You can
still get the benefits of garbage collection on everything else, so it's
still a win.

--Jeffrey Bosboom


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk