When stack overflow occuring, increasing stack reserve size is helpful while commit size isn't.
Would experts explain the difference bewteen reserve and commit size, and when to increase reserve size and when to increase commit size?
I have read some docs like that. According to the docs, I think commit have higher priority than reserve, since commit memory will allocate physical memory at a time, and reserve memory just reserve size in virtual memory.
But set commit size to a larger number can not solve stack overflow which can be solved by setting reserve size. Why?
I do not think that you can commit (one or more times accumulatively) more than reserve. IOW reserve must be set appropriately, and commit (if used by the runtime system) affects the size of the block committed to the page file/RAM (limited to the extent of the reserve size).
reserve == Block out this amount of Virtual Memory Address range for use as stack (not necessarily taking any resources until first used)
My usual recommendation is to set the option /heap-arrays (Fortran > Optimization > Heap Arrays > 0). This causes temporaries and automatic arrays to be allocated on the heap rather than the stack.
I have a Fortran DLL and a C++ executable. The article that Jim references says to only set stack and heap for exe. Is this really the case? How do I handle large arrays in the dll?
I am using a set of procedures called fox to read in xml. When I enable /heap-arrays the fox code crashes. It gives me an unhandled break and the locations are not even consistent .
>>When I enable /heap-arrays the fox code crashes.
Enable all compile time and run time diagnostics. The run time diagnostics may require a console window, or for Windows Program without console window, set the environment variable FORT0 to a file specification for stderr messages, and set environment variable FORT6 to that for stdout messages.
Do not set the value of /heap-arrays to anything but zero. Non-zero values are not useful. You are not setting the size of the heap. Theoretically, that value for /heap-arrays allows the compiler to keep small things on the stack and allocate large temps on the heap, but in practice the situations where it can do that are so restricted that it is pointless.