Be Aware: VirtualAlloc with MEM_RESERVE can fail even if you have plenty of VAS inside of the process

 Many developers assume that if you have plenty of free VAS in your process VirtualAlloc ( and VirtualAllocEx ( calls with MEM_RESERVE parameter can't fail. This is not actually true.  Remember that when allocating VAS region OS creates VAD (Virtual Address Descriptor). VAD manages VAS region, for more info read When system is low on physical memory which includes RAM and swap file, VAD's allocation might fail. The failure will cause VirtualAlloc* call to fail. It means that if system low on physical memory VirtualAlloc* could fail. This becomes very important on 64 bit platforms. When running on 64 bit, developers might assume that reservation never fails - which is wrong.

Hope it was useful.

Comments (0)

Skip to main content