Skip to content

Instantly share code, notes, and snippets.

@23Skidoo
Created October 30, 2014 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 23Skidoo/ae5cedb5e4717e96de3d to your computer and use it in GitHub Desktop.
Save 23Skidoo/ae5cedb5e4717e96de3d to your computer and use it in GitHub Desktop.
MEM_RESERVE gobs of memory on Windows happens instantly.
/* See https://ghc.haskell.org/trac/ghc/ticket/9706 */
#include <windows.h>
#include <stdio.h>
int main() {
printf("How many GB to reserve:");
SIZE_T numGB = 1;
scanf("%Iu", &numGB);
SIZE_T toReserve = numGB*1024*1024*1024;
printf("Trying to reserve %Iu bytes...\n", toReserve);
LPVOID addr = VirtualAlloc(NULL, toReserve, MEM_RESERVE, PAGE_NOACCESS);
printf("Got addr: %p\nPress any key...\n", addr);
getc(stdin);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment