Women in Technology

Hear us Roar

  Modern Memory Management, Part 2
Subject:   Garbage collection
Date:   2005-12-09 11:22:44
From:   Gerd_Stolpmann
The author says about garbage collection that it works only for "true leaks" which are blocks to which no pointer points to. Although there are some GC mechanisms for which this is true (namely reference counting), others are better. In particular, a truly modern GC (using the mark-and-sweep or stop-and-copy mechanisms or both) also finds blocks that cannot be reached by any reference path starting at a registered root (a global variable). In such memory management systems, it is very hard to produce memory leaks. Unfortunately, the LAMP languages are not that modern.

Furthermore, we can read this myth: "Additionally, the garbage collector is normally only activated when the process is idle, or explicitly called by the programmer." Nonsense! The author does not know anything about GCs. Good GCs are normally programmed as coroutines, i.e. every time a memory allocation is performed, a certain of amount of GC work is done. Although some systems increase that amount when nothing else is to do, they also do this when memory gets tight. If a memory allocation cannot be done, the GC coroutine is continued and runs until the allocation can be performed. This ensures that you really can recycle memory, no matter under which pressure the system is.

Can we please read facts and not myths?

Main Topics Oldest First

Showing messages 1 through 1 of 1.

  • Garbage collection
    2005-12-09 14:24:07  finesse [View]

    You are correct in that I am no expert on garbage collection (or Valgrind apparently), and that is why it is only mentioned briefly in one paragraph. I apologize if I have incorrectly explained Java Garbage Collection but that is my understanding of how it works.

    I think the more important point I was trying to make, however, is that regardless of how good it may get, GC is still no replacement for brains :)