1. A computer program product for managing memory in a computer system in which memory locations in use at any given time are represented as a set of memory objects in a first object graph that includes a system root object associated by references to each of said memory objects, the computer program product comprising: a computer-readable storage medium having computer-readable program code embodied therewith, wherein the computer-readable storage medium is not a transitory signal per se, the computer-readable program code executable by a processor to cause the processor to perform a method comprising: creating a second root object for said memory so as to form a second object graph for said memory; in response to a dereferencing of a first object from said first object graph, associating said dereferenced first object with said second object graph so that said second object graph comprises one or more dereferenced objects; removing, in response to associating said first object with said second object graph, the first object from memory; returning memory addresses allocated to the first object to a heap after removing the first object from memory; and reconstructing the first object graph using data stored in the second object graph.