This call allocates multiple segments as a huge block of memory.
DosAllocHuge
NumSeg (USHORT) - input
Bit
DosAllocHuge allows a process to allocate a large amount of memory by telling the system how many 64KB segments it needs and whether it requires an additional partial segment. The system allocates the memory, which is movable and swappable, and returns a selector to the first segment. When this selector is used with a call, the requested function is performed for the entire block of memory.
Each segment of a huge memory allocation has a unique selector. To determine the remaining selectors of a huge memory allocation, issue DosGetHugeShift, which returns a shift count. To compute the next sequential selector, take the value 1 and shift it left by the number of bits specified in shift count. Use the resulting value as an increment to add to the previous selector, using the selector returned by DosAllocHuge as the first selector. For example:
o
Like single segment memory allocated with DosAllocSeg, huge memory can be designated as shareable by other processes and discardable by the system when no longer needed. Allocating a huge block of memory as discardable automatically locks the memory for use by the caller. When one segment of a huge allocation is discarded by the system, this forces the discard of all the other segments. See DosAllocSeg for more information relating to discardable and shared segments.
Applications should be discretionary in claiming large memory when doing so can impair system performance. To test system memory availability, issue DosMemAvail. This call returns the size of the largest block of unallocated memory. Although this value can change at any time because of system activity , it can provide a good indication of the system memory state.
Memory allocated by DosAllocHuge is freed by DosFreeSeg. One call to DosFreeSeg, passing the selector returned from a DosAllocHuge, frees all of the memory allocated.
Note: This request may be issued from privilege level 2. However, the segment is allocated as a privilege level 3 segment.
Family API Considerations
Some options operate differently in the DOS mode than in the OS/2 mode. Therefore, the following considerations apply to DosAllocHuge when coding for the DOS mode:
o