DWORD GetFreeSpace(wFlags)
This function scans the global heap and returns the number of bytes of memory currently available.
Parameter | Type/Description | |
wFlags | WORD Specifies whether to scan the heap above or below the EMS bank line in large-frame and small-frame EMS systems. If it is set to GMEM_NOT_BANKED, GetFreeSpace returns the amount of memory available below the line. If wFlags is zero, GetFreeSpace returns the amount is the memory available above the EMS bank line. The wFlags parameter is ignored for non-EMS systems. |
The return value is the amount of available memory in bytes. This memory is not necessarily contiguous; the GlobalCompact function returns the number of bytes in the largest block of free global memory.
In standard mode, the value returned represents the number of bytes in the global heap that are not used and that are not reserved for code. In 386 enhanced mode, the value returned is calculated using the following formula:
Free_space = (heap – reserved) + (page_file + phys_pages) – (total_linear – free_linear) – 64K
In this formula:
heap is the number of unused bytes in the global heap.
reserved is the number of unused bytes in the global heap reserved for code.
page_file is the size of the paging file.
phys_page is the total size of physical pages.
total_linear is the total linear address space.
free_linear is the total unused linear address space
The return value in 386 enhanced mode is an estimate of the amount of memory available to an application. It does not account for memory held in reserve for non-Windows applications.