Search code examples
windowslinkerheap-memoryportable-executablestack-memory

"The default heap size is 1 MB". How come can I malloc() more then, do I misunderstand the word 'heap'?


In Microsoft Visual C++, I needed more stack space. So I went into the linker properties and raised it. But then I noticed another property: "Heap Reserve Size" (Linker Option: /HEAP) with the Note: "The default heap size is 1 MB".

How come I can malloc 50MB "on the heap" with a heap size of 1MB?

If I do the same with the stack, I get an out of stack space exception.


Solution

  • How come I can malloc 50MB "on the heap" with a heap size of 1MB?

    If I do the same with the stack, I get an out of stack space exception.

    That's because the heap can grow whereas the stack is fixed. 1MB is just the initial size of the heap.