[gambit-list] ReĄG Regarding garbage collection

Marc Feeley feeley at iro.umontreal.ca
Wed Sep 9 08:11:51 EDT 2009

On 9-Sep-09, at 5:36 AM, David Rush wrote:

>> As for the possibility of memory leaks, this puzzles me. In a  
>> language with garbage collection, what does it mean to have memory  
>> leaks?
> Exactly what you said yourself. Code that inadvertantly keeps memory
> around. Heavy use of symbols (in the sense of memoized strings) is
> probably the easiest way to leak memory. Just about anything that is
> linked to a a global data structure is a good candidate for leaking
> memory.
> If the garbage collector thinks your program could possibly ever use a
> piece of memory again, it will not free that memory. The collector is
> way more conservative than your brain, so it is certainly possible to
> fool yourself about whether or not you *intend*  to use data when you
> have in fact kept it around.

Nice explanation.

Simply: garbage collection solves the "dangling pointer" problem  
completely, and it only helps with the "memory leak" problem because  
you can write programs that keep references to data that will never be  
used by the program.  Garbage collectors are "conservative" in the  
sense that they use "reachability" to determine "usefullness" of data.


More information about the Gambit-list mailing list