Skip to Main Content U.S. Department of Energy
PNNL: High Performance Computing

Dynamic Memory Allocator

Memory Allocator(MA) is a library of routines that comprises a dynamic memory allocator for use by C, Fortran, or mixed-language applications. Fortran- 77 applications require such a library because the language does not support dynamic memory allocation. C (and Fortran-90) applications can benefit from using MA instead of the ordinary malloc() and free() routines because of the extra features MA provides:

  • both heap and stack memory management disciplines,
  • support for Fortran and C datatypes,
  • debugging and verification support including
    • guards protecting allocated memory blocks
    • detection of ovewritten ends of the allocated memory blocks by the application
    • ability to assign names to allocated memory blocks
  • usage statistics, and
  • quantitative memory availability information.

MA library can be obtained with the Global Arrays distribution package.

Implementation

Memory layout:
segment = heap_region stack_region
region = block block block ...
block = AD gap1 guard1 client_space guard2 gap2

A segment of memory is obtained from the OS upon initialization. The low end of the segment is managed as a heap; the heap region grows from low addresses to high addresses. The high end of the segment is managed as a stack; the stack region grows from high addresses to low addresses.

Each region consists of a series of contiguous blocks, one per allocation request, and possibly some unused space. Blocks in the heap region are either in use by the client (allocated and not yet deallocated) or not in use by the client (allocated and already deallocated). A block on the rightmost end of the heap region becomes part of the unused space upon deallocation. Blocks in the stack region are always in use by the client, because when a stack block is deallocated, it becomes part of the unused space.

A block consists of the client space, i.e., the range of memory available for use by the application; guard words adjacent to each end of the client space to help detect improper memory access by the client; bookkeeping info (in an "allocation descriptor," AD); and two gaps, each zero or more bytes long, to satisfy alignment constraints (specifically, to ensure that AD and client_space are aligned properly).

Site Links

Our Research

Past Research

Global Arrays Links

Memory Allocator (MA) Links

Contacts