A garbage collection process for managing a memory includes a
defragmentation cycle. The garbage collection process is interleaved with
a running application on a time-based or work-based schedule. The memory
is divided into pages which are further divided into blocks falling into
one of a number of block size classes. Objects that were not used by
applications during the last garbage collection phase are marked. Objects
that were used are moved from pages containing the least live objects to
pages containing the most live objects. Objects of the largest block size
classes are moved first and objects of the smallest block size class are
moved last. The garbage collection interval can be selected to satisfy
desired CPU utilization or memory overhead requirements.