Wednesday, May 20, 2015

Lindy Effect : Java Garbage collector


This post is a new one in a row of Lindy Effect in Software Engineering.

Lindy Effect states that : the life expectancy of non-perishable things that posits for a certain class of nonperishables, like a technology or an idea, every additional day may imply a longer life expectancy.


In software memory usage is one of the most important things. Some data doesn't need to be persistent in memory forever, and should be deleted after becoming not needed.

Up to 70-s in most computer languages developers need to clean (remove not needed data) directly.

In many recent languages a new form of automatic memory management garbage collection could be used instead.

With these technology developers don't need to keep in mind if some data is not needed - the system will remove it in most cases automatically.

In Java garbage collector works on the following procedure (a bit simplified):
  1. the memory is divided in 3 spaces : young generation (eden,  survivor), old generation (tenured)
  2. when new data appears it appears in eden space
  3. whenever free memory is low eden space is checked: not referenced data is automatically deleted, the rest moved to survivor space
  4. whenever free memory is very low survivor space is checked:not referenced  data is automatically removed - cleaned, the rest either remains either in survivor space of moved to tenured space depending on data age
  5. whenever free memory is extremely low then tenured space is checked and not referenced data is removed from there
 Steps 3..5 were designed due to "empirical analysis of applications has shown that most objects are short lived." (Java Garbage Collection Basics: Why Generational Garbage Collection).


But that procedure could be considered as an application of a Lindy Effect as well: the data which survived longer has higher probability to survive longer.