3.2 Memory-Management Functions

Memory-management functions manage system memory. There are two categories of memory-management functions: those that manage global memory and those that manage local memory. Global memory is all memory in the system that

has not been allocated by an application or reserved by the system. Local memory is the memory in the data segment of a Windows application. Following are the memory-management functions:

Function Description

GetFreeSpace Retrieves the number of bytes available in the global heap.
GetFreeSystemResources Returns the percentage of free system-resource space.
GetWinFlags Retrieves information about the system-memory configuration.
GlobalAlloc Allocates memory from the global heap.
GlobalCompact Compacts global memory to generate free bytes.
GlobalDosAlloc Allocates global memory that can be accessed by MS-DOS.
GlobalDosFree Frees global memory previously allocated by the GlobalDosAlloc function.
GlobalFlags Returns the flags and lock count of a global memory object.
GlobalFree Removes a global memory object and invalidates the handle of the memory object.
GlobalHandle Retrieves the handle of a global memory object.
GlobalLock Retrieves a pointer to a global memory object speci-fied by a handle. Except in the case of nondiscardable objects in protected (standard or 386-enhanced) mode, the object is locked in memory at the given address and its lock count is increased by one.
GlobalLRUNewest Moves a global memory object to the newest least recently used (LRU) position.
GlobalLRUOldest Moves a global memory object to the oldest LRU position.
GlobalNotify Installs a notification procedure for the current task.
GlobalReAlloc Reallocates a global memory object.
GlobalSize Returns the size, in bytes, of a global memory object.
GlobalUnlock Invalidates the pointer to a global memory object previously retrieved by the GlobalLock function. If the object is discardable, GlobalUnlock decreases the lock count of the object by one.
GlobalUnWire Decreases the lock count set by the GlobalWire function, and unlocks the memory object if the count is zero.
GlobalWire Moves an object to low memory and increases the lock count.
LimitEmsPages Limits the amount of expanded memory that Windows assigns to an application.
LocalAlloc Allocates memory from the local heap.
LocalCompact Compacts local memory.
LocalFlags Returns the memory type of a local memory object.
LocalFree Frees a local memory object from memory if the lock count is zero and invalidates the handle of the memory object.
LocalHandle Retrieves the handle of a local memory object.
LocalInit Initializes a local heap in the specified segment.
LocalLock Locks the local memory object by increasing its lock count.
LocalReAlloc Reallocates a local memory object.
LocalShrink Shrinks the local heap.
LocalSize Returns the size, in bytes, of a local memory object.
LocalUnlock Unlocks a local memory object.
LockSegment Locks a specified data segment in memory.
SetSwapAreaSize Increases the amount of memory that an application reserves for code segments.
SwitchStackBack Returns the stack of the current task to the task's data segment after it had been previously redirected by the SwitchTasksBack function.
SwitchStackTo Changes the stack of the current task to the specified data segment, such as the data segment of a dynamic-link library (DLL).
UnlockSegment Unlocks a specified data segment.