SetOOMEvent

This function enables enhanced memory management features of Windows CE.

void SetOOMEvent(
  HANDLE hEvent,
  DWORD cpLow,
  DWORD cpCritical,
  DWORD cpLowBlockSize,
  DWORD cpCriticalBlockSize 
);

Parameters

  • hEvent
    [in] Handle to the event that the kernel will set when memory has become low or critically low.
  • cpLow
    [in] Number of free memory pages that will trigger a low memory condition. When memory goes below this level, hEvent is set.
  • cpCritical
    [in] Number of free memory pages that will trigger a critically low memory condition. When memory goes below this level, hEvent is set.
  • cpLowBlockSize
    [in] Size of the largest block that the kernel will allocate with the VirtualAlloc function when the allocation would leave the system with fewer than cpLow pages.
  • cpCriticalBlockSize
    [in] Size of the largest block that the kernel will allocate with VirtualAlloc when the allocation would leave the system with fewer than cpCritical pages.

Return Values

None.

Remarks

This function replaces SetGwesOOMEvent, which is now obsolete. There is no need to call this function in an OS configuration that includes the OOM component. The OOM component calls this function and relies on registry settings to define the OEM's preferred memory settings. If there are no registry settings, the OOM component will use the following parameter defaults:

  • cpLow = 32
  • cpCritical = 20
  • cpLowBlockSize = 4
  • cpCriticalBlockSize = 2

If an OEM does not include the OOM component, the OEM must call this function to enable control of the following resources:

  • Page-out code. When memory is low, the kernel will page out or discard code that is marked as discardable. This enables memory to be freed for use by other processes.
  • Reclaim unused stack space. When memory is low, the kernel will attempt to reclaim memory used by a thread's stack that is no longer needed by the thread.

If this function is not called, the following defaults for the system are used:

  • cpLow = 0
  • cpCritical = 0
  • cpLowBlockSize = 0
  • cpCriticalBlockSize = 0

The kernel will not attempt to page out code until memory reaches zero and it will not reclaim unused stack memory. However, memory will be reclaimed when threads, processes, memory, and kernel objects are deleted. In some circumstances, a system that does not discard memory or reclaim stack memory is usable by the OEMs. An OEM must completely investigate all the issues before deciding not to call this function.

An application that needs to monitor a memory state would pass in the parameters, and then wait for the event to be triggered by the kernel by calling the function WaitForSingleObject. When the kernel sets the event, the monitoring application would query the memory state to determine if memory was low or critical and take the appropriate action. To query the current memory state, use the GlobalMemoryStatus function.

Requirements

OS Versions: Windows CE 3.0 and later.
Header: Pkfuncs.h.
Link Library: Coredll.lib.

See Also

dwNKMaxPrioNoScav | GlobalMemoryStatus | VirtualAlloc | WaitForSingleObject

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.