GlobalCompact

Syntax

DWORD GlobalCompact(dwMinFree)

This function generates the number of free bytes of global memory specified by the dwMinFree parameter by compacting and, if necessary, discarding from the system's global heap. The function always compacts memory before checking for free memory. It then checks the global heap for the number of contiguous free bytes specified by the dwMinFree parameter. If the bytes do not exist, the GlobalCompact function discards unlocked discardable blocks until the requested space is generated, whenever possible.

Parameter Type/Description  

dwMinFree DWORD Specifies the number of free bytes desired.  

Return Value

The return value specifies the number of bytes in the largest block of free global memory.

Comments

If dwMinFree is zero, the return value specifies the number of bytes in the largest free segment that Windows can generate if it removes all discardable segments.

If an application uses the return value as the dwBytes parameter to the GlobalAlloc function, the GMEM_NOCOMPACT or GMEM_NODISCARD flags should not be used.