3.2 Memory-Management Functions

Memory-management functions manage system memory. There are two categories of 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 within a Windows application's data segment. The following list briefly describes each memory-management function:

Function Description  
DefineHandleTable Creates a private handle table in an application's default data segment.  
GetFreeSpace Retrieves the number of bytes available in the global heap.  
GetWinFlags Retrieves information about the system memory configuration.  
GlobalAlloc Allocates memory from the global heap.  
GlobalCompact Compacts global memory to generate free bytes.  
GlobalDiscard Discards a global memory block if the lock count is zero, but does not invalidate the handle of the memory block.  
GlobalDosAlloc Allocates global memory that can be accessed by DOS running in real or protected mode.  
GlobalDosFree Frees global memory previously allocated by the GlobalDosAlloc function.  
GlobalFlags Returns the flags and lock count of a global memory block.  
GlobalFree Removes a global memory block and invalidates the handle of the memory block.  
GlobalHandle Retrieves the handle of a global memory object.  
GlobalLock Retrieves a pointer to a global memory block specified by a handle. Except for nondiscardable objects in protected (standard or 386 enhanced) mode, the block is locked into 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 least-recently-used (LRU) position.  
GlobalNotify Installs a notification procedure for the current task.  
GlobalReAlloc Reallocates a global memory block.  
GlobalSize Returns the size (in bytes) of a global memory block.  
Function Description  
GlobalUnlock Invalidates the pointer to a global memory block previously retrieved by the GlobalLock function.
In real mode, or if the block is discardable, GlobalUnlock decreases the block's lock count
by one.
 
GlobalUnwire Decreases the lock count set by the GlobalWire function, and unlocks the memory block 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 will assign to an application.  
LocalAlloc Allocates memory from the local heap.  
LocalCompact Compacts local memory.  
LocalDiscard Discards a local memory block if the lock count is zero, but does not invalidate the handle of the memory block.  
LocalFlags Returns the memory type of a local memory block.  
LocalFree Frees a local memory block from memory if the lock count is zero and invalidates the handle of the memory block.  
LocalHandle Retrieves the handle of a local memory object.  
LocalInit Initializes a local heap in the specified segment.  
LocalLock Locks a block of local memory by increasing its lock count.  
LocalReAlloc Reallocates a local memory block.  
LocalShrink Shrinks the local heap.  
LocalSize Returns the size (in bytes) of a local memory block.  
LocalUnlock Unlocks a local memory block.  
LockData Locks the current data segment in memory.  
LockSegment Locks a specified data segment in memory.  
SetSwapAreaSize Increases the amount of memory that an application reserves for code segments.  
Function Description  
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).  
UnlockData Unlocks the current data segment.  
UnLockSegment Unlocks a specified data segment.