摘要 |
In a computer system, a dynamic memory allocation and recovery system and method, sometimes referred to as a garbage collection system and method, provides a heap of storage space for storing program objects generated by a task. The heap is divided into pages whose size is independent of physical page sizes used by the computer system. Pages are denoted an unallocated or allocated for storing program objects. A root stroage area stores information called hints regarding program objects stored in the heap. The hints can include ambiguous pointers which may or may not point to program objects stored in the heap. Garbage collection is performed by promoting and retaining all pages in the heap which are referenced by hints, and by copying into previously unallocated pages all other accessible program objects in the heap. All pointers to the copied program objects are replaced with pointers to the new copies of those program objects. As a result, all program objects located in pages pointed to by ambiguous pointers are left in their original position, and only the pointers to the copied program objects are replaced with pointers to the new copies of the program objects. After garbage collection, the set of allocated pages for the task includes all promoted and retained pages pointed to by ambiguous pointers as well as all pages containing the new copies of the copied program objects. All other pages in the heap become the unallocated pages available for storing new program objects generated by the task.
|