I have a call to calloc
for 1 element of just over 1 gigabyte. This call returns NULL
, and checking errno reveals an insufficient memory error. However, during testing I have almost 4 gigabytes of free RAM, not to mention available virtual memory.
After researching the issue, the only thing I can come up with for why calloc
fails is that I do not have enough contiguous memory available. However, it seems to me that if I have 4Gb available memory, it should be easy enough to have ~= 1Gb contiguous memory. Is there a way to check for contiguous memory availability? If this is the problem, is there a straightforward way to "defragment" the memory?
Or does this have something to do with the block size of allocated memory, so that it is actually trying to allocate way more memory than I have available? What are my options for determining cause of failure? What are my options for successfully allocating this much memory?
I am on a native Windows system with 12Gb of memory. Next I will try running in a VM, and giving the VM several gigabytes of memory, and checking if the virtual machine can non-transparently access enough contiguous memory. I will post the results here if I complete that today.