On Mon, Mar 31, 2014 at 7:27 PM, Joel VanderWerf
[email protected] wrote:
Ok, trying to generate some discussion on ruby-talk:
GC is an interesting topic indeed!
A few days ago this article pointed out how generational GC in ruby is
potentially dangerous for production systems.
Someone asked on lobste.rs why ruby is being singled out here. Isn’t this
a danger for all languages with gen GC? 
That depends on the implementation. On Java’s JVM I have never seen
this. But there you can get long pauses because fragmented memory
triggers a full GC (pre G1).
There is a fundamental problem that no GC can solve completely because
it would require an oracle: long lived objects are usually expensive
for GC. The more often you look at a long lived object without being
able to collect it the more expensive it is (in terms of CPU cycles).
There are various approaches to remedy that to some extent and gen GC
is one of them. But, it cannot get rid of that issue completely: even
if you look at objects in old gen more rarely than you do in young gen
there are typically still some long lived objects (configuration,
central caches) which become more and more costly.
It’s even worse if you have long lived objects that do not live for
the whole application duration but only for a certain period which is
still longer than what the young gen covers. Then you additionally get
the cost of allocation for all these from time to time new objects.
Introducing some manual element (e.g. marking objects obsolete once we
know they are not used any more) is tricky as well especially if you
consider references between “manual” and “automatic” objects. If you
introduce two types of objects the nice aspect of the uniform world of
objects goes away. Etc.
One sign for the complexities of GC is the time it took for Java’s G1
to become production ready: if you look at the research paper you’ll
notice they started work on a pre alpha of Java 5 and it was stamped
production ready in Java 7 (not the initial release). I think all in
all it took 7 years and some quite involved math and implementation
from the first ideas to the fully released version.