A method and mechanism for managing dynamically allocated memory. Portions
of memory which are available for allocation have additional information
stored in association with each portion which indicates whether the
portion has been previously identified as being prematurely freed. In
addition, a checksum is stored with each portion of memory. In response
to a request for deallocation of a portion of memory, the portion of
memory is not deallocated if it is identified as having been prematurely
freed. Otherwise, the a checksum is calculated for the portion and it is
freed. In response to an allocation request, a candidate portion of
memory is identified for allocation and a checksum is calculated for the
candidate portion. If the calculated checksum does not match a checksum
previously stored for the candidate portion, the portion is identified as
having been prematurely freed and is not returned for allocation.