How to handle STATUS_NO_MEMORY : 0xC0000017

Hello,

I am using private heaps in my application.
The request to HeapAlloc using my private heap fails when the available
virtual memory is less and windows tries to increase the virtual memory
size.

Is there any way to detect that windows is increasing the virtual memory
size, wait and then call HeapAlloc so that the request to HeapAlloc
succeeds.
Should I catch this exception, wait and again call HeapAlloc? Is there a
better way to do this?

Thanks.

Regards,
Mandar G. Nanivadekar,
HP Storage Lab,
IInd Floor, Hulkul Brigade,
82, Lavelle Road,
Bangalore - 1