A method, system, and computer program product for managing a heap of
memory allocated to a program being executed on a data processing system
is disclosed. A limited amount of memory is allocated to a program being
executed by a mutator on a data processing system. The memory comprises
memory objects. The disclosed method identifies memory objects, which are
allocated to the program but are not referenced anymore. These dead
memory objects are freed and made available for further allocation in the
program. The memory objects that are still referenced are organized in
compact contiguous blocks. Thus, the disclosed method recycles memory
allocated to the program. The disclosed method is executed iteratively
and concurrently with the execution of the program. The disclosed method
does not interfere with program execution. Amount of memory required is
specified before the commencement of the disclosed method and the same
amount is freed without any surplus.