Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
About Heaps (1.2)
◄Using Section► ◄Function Group► ◄Up► ◄Next► ◄Previous►
────────────────────────────────────────────────────────────────────────────
About Heaps
This topic describes the functions that allow you to use heaps for memory
management in your applications. You should also be familiar with the
following topic:
◄Memory manager►
A heap is a memory segment containing other memory-block objects that are
allocated and deallocated by the functions of the heap manager (the group of
functions that manage heaps in MS OS/2). The heap functions are provided to
supplement, and in some cases replace, the basic memory-management functions
of MS OS/2. The heap functions provide more functionality than the basic
memory-management functions, including movable objects within a segment and
faster allocation implementation.
A heap exists within a memory segment. The segment can be the automatic data
segment of an application or dynamic-link module, or it can be another
segment that has been allocated explicitly by using the DosAllocSeg
function. Typically, the heap is part of an automatic data segment, and it
shares that segment with the application's static data and stack. The
combined size of the heap, static data, and stack cannot be larger than
64K──the maximum segment size in MS OS/2. Heaps allocated in separate
segments also cannot be larger than 64K.
A heap typically contains many memory-allocation objects. Each object is
accessed by an offset (near pointer) from the beginning of the segment.
Notice that the beginning of the heap is not necessarily at the beginning of
the segment. For heaps in the automatic data segment, the application or
dynamic-link module can use the near pointer to the memory object directly,
because the data-segment selector is implicit. For heaps allocated in
separate segments, the near pointer must be combined with the segment
selector to make a far pointer.
A heap can be created so that objects within the heap are movable. This
allows the system to rearrange objects on the heap to make more free memory
available and avoid heap fragmentation.
MS OS/2 attempts to make the heap larger if a memory-allocation request
cannot be filled by using the existing heap. This growth is controlled by
setting growth limits when the heap is created.
♦