Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 15
Checking the Bounds of Your Data Areas
A nonzero value indicates that there was not enough room and the stack could not
be enlarged. The value also indicates the reason why the stack could not be
enlarged (for example, the maximum allowable stack size would be exceeded, or
memory or swap space could not be allocated).
If called from a nonprivileged procedure, HEADROOM_ENSURE_ operates on the
main stack; if called from a privileged procedure, it operates on the priv stack.
You might want to use HEADROOM_ENSURE_ in the following cases:
If your application uses unusually large local arrays or structs, or has many nested
procedure calls, it can use HEADROOM_ENSURE_ to test whether the stack size
is near the limit. You can then take appropriate action. (A stack overflow signal or
trap results if a process attempts to increase the stack size beyond the limit.)
If your application contains privileged procedures with unusually large stack
requirements, it might need to call HEADROOM_ENSURE_, because the priv
stack does not automatically increase as it is used.
Refer to the Guardian Procedure Calls Reference Manual for details on the
HEADROOM_ENSURE_ procedure.
Reserving Swap Space
The SPACE^GUARANTEE process attribute establishes an amount of disk space to
be used for all virtual memory requested by a process. This includes the globals-heap
segment, the main stack, all the SRL data segments, and any flat segments allocated
with default swapping. You can specify a value for this attribute in the
PROCESS_LAUNCH_ procedure call or through NLD. Supplying this attribute allows
a process to reserve enough memory and swap space when the process starts to
ensure that execution will not be impacted by lack of swap space.
The value of the SPACE^INUSE process attribute indicates the amount of swap space
currently available to a process. You can find out the current value of this attribute by
calling the PROCESS_GETINFOLIST_ procedure and specifying the space_inuse
parameter.
Checking the Bounds of Your Data Areas
You can use the ADDRESS_DELIMIT_ procedure to obtain the addresses of the first
and last bytes of a particular area of your logical address space, such as your user
data segment (TNS processes) or your globals-heap segment (native processes), and
of your main and priv stacks. Knowing the bounds of your data area allows you, for
example, to check parameter addresses.
You supply an address contained within the address area of interest, passing it to
ADDRESS_DELIMIT_ in the value parameter address. You can also use the
Note. Using the SPACE^GUARANTEE attribute to guarantee swap space is necessary only in
unusual circumstances.