none
Allocating 2/4+ GigaBytes of Memory... RRS feed

  • Question

  • I normally allocate memory this way....
    HeapAlloc(GetProcessHeap(),0,MemorySizeInBytes);
    


    But there is a chance with I am doing (not a big chance, but still a chance) that I may need a contiguous block of memory larger than 2/4Gig....

    If someone knows, how would I do this?

    Also - as a side note, is there an easy way to determine machine memory? What about how much memory is left to my application?

    Tuesday, December 20, 2011 12:58 PM

Answers

  • I assume this is a 64 bit program. (after all, a 4 GB allocation has no hope of succeeding in 32 bit)

    If this is a 64 bit program, why can't you use HeapAlloc?  HeapAlloc takes a SIZE_T (which is 64 bits when compiled for 64 bit Windows)

    • Marked as answer by V3ngeanc3 Tuesday, December 20, 2011 3:52 PM
    Tuesday, December 20, 2011 1:27 PM

All replies

  • I assume this is a 64 bit program. (after all, a 4 GB allocation has no hope of succeeding in 32 bit)

    If this is a 64 bit program, why can't you use HeapAlloc?  HeapAlloc takes a SIZE_T (which is 64 bits when compiled for 64 bit Windows)

    • Marked as answer by V3ngeanc3 Tuesday, December 20, 2011 3:52 PM
    Tuesday, December 20, 2011 1:27 PM
  • Sorry, the documentation I looked at said it was a DWORD, point taken...
    Tuesday, December 20, 2011 3:52 PM