1. A method for memory management in execution of a program by a computer having a memory, comprising: setting an attribute of an unallocated unit of the memory in preparation for allocation of the memory in the unit; allocating respective portions of the memory in the unit to data objects to be held in a heap created by the program; responsive to the attribute that is set on the allocated portions of the memory, tracing the data objects in the heap so as to mark the data objects that are reachable at a given stage in the program; and sweeping the heap so as to free the memory that is allocated to data objects that are not marked as reachable, for reallocation to new data objects.