Windows CE uses the WM_HIBERNATE message as its primary mechanism for asking applications to free memory. When freeing memory is required, the system posts the message to one or more applications, beginning with the application that has been inactive the longest. It requests memory from the active application last and does not send WM_HIBERNATE messages to invisible windows.
Note Hibernating is vital for applications running on an H/PC. All H/PC applications must have a handler for WM_HIBERNATE.
When the system brings an application to the foreground, it sends an WM_ACTIVATE message. If the hibernating application has previously released memory, the system does not restore its memory resources to the prehibernation state. Applications should have a WM_ACTIVATE handler that can restore memory resources following hibernation.
An application must take the following actions when it receives a WM_HIBERNATE message:
As the amount of available memory drops, the system posts WM_HIBERNATE messages at an increasing rate. If the system reaches a situation where a call to VirtualAlloc is about to fail, it tries to free pages by shrinking stacks. The system shrinks stacks in random order to minimize the risk of a stack fault, which causes an application to fail. The system also frees memory by discarding read-only pageable pages. If the system cannot free any stack pages, VirtualAlloc fails, and the function is returned to the application as a failed function call.