SetOOMEvent (Windows CE 5.0)

Send Feedback

This function enables enhanced memory management features of Windows CE.

void SetOOMEvent(HANDLEhEvent,DWORDcpLow,DWORDcpCritical,DWORDcpLowBlockSize,DWORDcpCriticalBlockSize );

Parameters

  • hEvent
    [in] Handle to the event that the kernel sets when memory becomes low or critically low.
  • cpLow
    [in] Number of free memory pages that triggers a low memory condition. When memory goes below this level, hEvent is set.
  • cpCritical
    [in] Number of free memory pages that triggers a critically low memory condition. When memory goes below this level, hEvent is set.
  • cpLowBlockSize
    [in] Size of the largest block that the kernel allocates 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 allocates 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 uses 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 pages out or discards code that is marked discardable. This enables memory to be freed for use by other processes.
  • Reclaim unused stack space. When memory is low, the kernel attempts 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 does not attempt to page out code until memory reaches zero, and it does not reclaim unused stack memory. However, memory is 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 OEMs. An OEM must completely investigate 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 is low or critical, and then take 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 | Out-of-Memory Registry Settings

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.