Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 19
Overview of Flat Segments
17 Managing Memory
Overview of Flat Segments
The second type of extended data segment is the flat segment. You can allocate
space for multiple flat segments, and all are accessible to the process that allocated
them. Each flat segment is allocated at a different starting address on a 32-megabyte
boundary (G04.00 and earlier G-series releases and all D-series releases; there is no
boundary. In G05.00 and later G-series releases, only a limit of 1120 megabytes. In all
H-series and J-series releases the limit is 1536 megabytes), and they do not overlap.
All flat segments are accessible at the same time; unlike selectable segments, you
need not make a flat segment the current segment in order to access it.
When you allocate a flat segment, you will generally allow the
SEGMENT_ALLOCATE_ procedure to determine and return its starting address. You
can optionally specify the starting address for a flat segment, but under most
circumstances, this is not recommended.
For flat segments in a native mode process, the address space used for flat segments
is also used for the heap (which is used by C / C++ applications). Flat segments (when
allocated by Guardian) are assigned starting at the highest address and going
downward. The heap starts at the lowest address and grows upward. This means, for
native mode programs, the maximum segment size is not 1120 MB. It depends on
how much heap space the program uses. At best, a native mode program has 1119
MB available for flat segments (it could have less available if the heap has grown to
greater than 1 MB). An attempt to allocate an 1120 MB segment in a native program
results in an error 15.
Figure 17-6 shows addressable areas of virtual memory for user data in a native
process. Note that at any given time, a process can address all of the following:
All flat segments
One selectable segment (the current one)
Global data
The heap
The main stack