Chapter Contents |
Previous |
Next |
SIGFPE |
Several new functions have been added allow a program to make use of
more than one heap. All programs contain at least 2 heaps; a library heap
and a standard heap. Library routines that need dynamic memory will allocate
from the library heap. Normally, this memory is internally used and not accessable
to the user. The standard heap is where memory will be allocated from by calls
to malloc
, pool
, calloc
etc. This heap can be predefined with attributes other
than the default. At program start, the standard heap is also the default
heap. Additional heaps can be created and declared as the default heap by pushing the new heap onto the heap stack. Calls to malloc
calloc
, free
, pool
, realloc
(For brevity, the rest of this description will
use malloc
as the general term for getting heap memory.) will
allocate memory from whatever is the current default heap. Additional functions
are available to get memory from a specific heap without making it the default
heap.
A heap is represented by a heap ID, which is an opaque token returned
by the hpcreate
function. hpcreate
is passed a heap attribute structure, which defines
the required behavior and properties of the heap. multheap.h
defines the various attributes that can be set for a heap.
These include location in memory (that is, above or below the bar/line) subpool
number, initial and overflow sizes, whether the heap can be shared between
subtasks and more. For above the bar heaps (heaps with virtual addresses greater
than 2G), the maximum guaranteed size of the heap is 2G, although the heap
may reach a hard limit of 4G. If more than 2G of contiguous memory is needed,
then the IARV64
function should be used.
The attributes of the standard heap can be set by defining an external
variable _heapdef
and initializing it with
the required attributes. For example, to have the standard heap be placed
above the 2G bar, specify:
extern _heap_attr _heapdef = {0, 0, 0, 0, 0, 0, HPLOC_64}
Attributes specified in this way override those set through previous
methods (the _heap
variable and the =/mmm
runtime option).
_heap_attr |
The _heap_attr
structure in multheap.h
defines the attributes of a heap. This
structure
is passed to hpcreate
to create a new heap
with these characteristics.
int version;
int flags;
HPATTR_SHARED
HPATTR_ZERO
HPATTR_NOUSAGE
=usage
for more information.
HPATTR_NOABEND
HPATTR_RETAIN
hpdestroy
.
HPATTR_SIGOK
malloc
is called from a
signal handler and the default heap does not have this indication, then the
most recent heap created with this indication will be used for allocation.
The non-shared heap list is searched before looking at the shared heaps.
char *area;
area
. This in effect
allows a heap within a heap. There is no protection against the owner of
this area freeing the storage so care must be taken when using this field.
The envisioned use of this would be for a number of callers to be able to
use separate heaps without the overhead of getting the memory directly from
the operating system. Rather, a large allocation would be done for all of
the callers and multiple virtual heaps would be created from that area.
unsigned int initial;
unsigned int overflow;
malloc
s beyond the initial amount will
fail.
int subpool;
char amode;
HPLOC_64
will get memory above the 2G
bar.
HPLOC_BELOW
HPLOC_ANY
HPLOC_64
HPLOC_RES
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2004 by SAS Institute Inc., Cary, NC, USA. All rights reserved.