Handmade Hero»Forums»Code
The_8th_mage
69 posts / 1 project
Virtual alloc fail
Hello,
I can't understand why my virtual alloc fails when i want to allocate more than a GiB. I thought that virtual memory makes the physical memory transparent and so on 64b i can allocate any amount i want, but i still get the no address failure 487 when i pass 0 to the base address.
Mārtiņš Možeiko
2358 posts / 2 projects
Virtual alloc fail
Are you sure you are running code as 64-bit not 32-bit?
Are you sure you are passing 0 in first argument (lpAddress)?
The_8th_mage
69 posts / 1 project
Virtual alloc fail
Yes, on both accounts.
Mārtiņš Možeiko
2358 posts / 2 projects
Virtual alloc fail
Edited by Mārtiņš Možeiko on
Then there is no way VirtualAlloc will return 487 error. Something else is wrong with your code.

Post minimal code that reproduces issue. Ideally only WinMain function with call to VirtualAlloc function + error check and nothing else.
Timothy McCarthy
52 posts
Virtual alloc fail
The only thing I can think of is if the Virtual memory address space has been fragmented such that there is no contiguous block available. This would be very unusual, I think.

- tim