Questions & Answers

HeapCreate with dwMaximumSize > 4GB

Is there any way to create a heap that is larger than 4 GB using the HeapCreate() function?

A heap bigger than 4 GB can be achieved by setting the dwMaximumSize parameter to zero and then asking for memory chunks. But this causes the individual parts of the heap to be split by the MEM_RESERVED chunks. I would need to create a continuous heap that has 5GB and is not divided by these MEM_RESERVED chunks.

The HeapCreate() function's dwMaximumSize parameter is of the SIZE_T type, which should allow setting this value to a higher value than 4 GB on a 64-bit system. However, when I try to allocate such a heap (larger than 4GB), HeapCreate() returns a null pointer. However, I haven't found anywhere documented that the HeapCreate() function should only allow the allocation of a heap that has dwMaximumSize parameter less than 4GB.

2023-01-25 00:00:04
Possibly related:: 64 bit large mallocs. I found this particularly interesting: Memory Limits for Windows and Windows Server Releases: "User-mode virtual address space for each 64-bit process: Limit in 64-bit Windows: With IMAGE_FILE_LARGE_ADDRESS_AWARE set (default): 7-128 TB (depending on CPU and OS version). 2 GB with IMAGE_FILE_LARGE_ADDRESS_AWARE cleared" I wonder if that is really true, or if it is a typo?
Answers(0) :