Go to the first, previous, next, last section, table of contents.


2.2 General Memory Terms and Concepts

To programmers, a heap is a bunch (or pile) of memory. Programs can make calls to allocate some memory from the heap to process a file (for example). When the program is done with the memory, it can free it back to the heap so that other parts of the program can use it. Heap memory is most useful when you do not know ahead of time the memory necessary to complete a task. The file could be large or small and allocating a small static space wouldn't be enough to process a large file while allocating a large space might waste system resources.

This ability to dynamically allocate space so you can perform a task or store a value is called (drum roll please) dynamic memory. Dynamic memory functions such as malloc, realloc, free, etc. provide dynamic storage functions for memory inside your application. The Diskheap library provides dynamic storage functionality similar to the in-memory heap functions but on disk.

When some space is allocated in the heap, the library returns its location as a block-number and offset pair of 32-bit unsigned integers. Both the block-number and the offset must be provided to retrieval, update, delete, and other functions to reference this space in the future.


Go to the first, previous, next, last section, table of contents.

Diskheap Home Page. Copyright 2002 by Gray Watson