Memory Allocation
l Dynamic Optimizers also do better memory
optimization
Two stage memory allocation allows very efficient
allocation of short-lived objects
l Objects are initially allocated in a “nursery”
Allocated in contiguous stack-like fashion – very fast
Most objects in the nursery have been discarded before the
nursery becomes full
l Only long lived objects need to be moved to long-term
storage
Java objects can be moved in memory (unlike C++)
l Objects with many cross-references can be moved closer
together
l Memory fragmentation can be eliminated
33