摘要 |
A computer method and system for coalescing free space in a heap data structure. In preferred embodiments, the heap comprises a plurality of sequential pages (segments), and each page is logically divided into blocks of memory that are either free or allocated. Each block resides in a single page. According to the present invention, a source pointer and a destination pointer advance through the pages. The source pointer is advanced to point to an allocated block to be copied. The destination pointer is advanced to point to an area in which the block currently pointed to by the source pointer can be copied. The block pointed to by the source pointer is then copied to the area pointed to by the destination pointer, and the source and destination pointers are advanced. When the destination pointer advances to an area that is not large enough to hold the block pointed to by the source pointer, a free block is created out of the area.
|