Application Hibernation on the Palm-size PC

The Palm-size PC shell uses the WM_HIBERNATE message as one of its mechanisms for asking applications to free memory. When freeing memory is required, the system posts this 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 Because the Palm-size PC shell closes applications automatically, you do not have to use the WM_HIBERNATE message. However, if you use it, your application does not have to start up as often.

When the system brings an application to the foreground, it sends an WM_ACTIVATE message. If the hibernating application has released memory previously, the system does not restore its memory resources to the pre-hibernation state. Applications should have a WM_ACTIVATE handler that can handle the restoration of 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.