42 - 05/06/09 18:40:24 CS61B: Lecture 42 Wednesday, May 6,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
05/06/09 18:40:24 1 42 CS61B: Lecture 42 Wednesday, May 6, 2009 Generational Garbage Collection ------------------------------- Studies of memory allocation have shown that most objects allocated by most programs have short lifetimes, while a few go on to survive through many garbage collections. This observation has inspired generational garbage collectors, which separate old from new objects. A generational collector has two or more generations, which are like the separate spaces used by copying collectors, except that the generations can be of different sizes, and can change size during a program’s lifetime. Sun’s 1.3 JVM divides objects into an old generation and a young generation. Because old objects tend to last longer, the old generation doesn’t need to be garbage collected nearly as often. Hence, the old generation uses a compacting mark-and-sweep collector, because speed is not critical, but memory efficiency might be. Because old objects are long-lived, and because mark and sweep only uses one memory space, the old generation tends to remain compact. The young generation is itself divided into three areas. The largest area is called "Eden", and it is the space where all objects are born, and most die. Eden is large enough that most objects in it will become garbage long before it gets full. When Eden fills up, it is garbage collected and the surviving objects are copied into one of two _survivor_spaces_. The survivor spaces are just the two spaces of a copying garbage collector. If an unexpectedly large number of objects survive Eden, the survivor spaces can expand if necessary to make room for additional objects. Objects move back and forth between the two survivor spaces until they age enough to be _tenured_ - moved to the old generation. Young objects benefit from the speed of the copying collector while they’re still wild and prone to die young. Thus, the Sun JVM takes advantage of the best features of both the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2010 for the course CS 61B taught by Professor Canny during the Spring '01 term at University of California, Berkeley.

Page1 / 2

42 - 05/06/09 18:40:24 CS61B: Lecture 42 Wednesday, May 6,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online