ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  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?


1 to 1 of 1
1 to 1 of 1