Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
110 Views

How to understand stack reserve size and commit size?

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?

Thanks!

0 Kudos
12 Replies
Highlighted
110 Views

Google: stack reserve commit

0 Kudos
Highlighted
New Contributor I
110 Views

Thanks, Jim.

Thanks, Jim.

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?

0 Kudos
Highlighted
110 Views

I do not think that you can

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)

Jim Dempsey

0 Kudos
Highlighted
Black Belt
110 Views

My usual recommendation is to

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. 

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
New Contributor I
110 Views

Thanks Steve, Your advise is

Thanks Steve, Your advise is very valuable!

And Thanks Jim! 

0 Kudos
Highlighted
110 Views

I have a Fortran DLL and a C+

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?

 

Michael

0 Kudos
Highlighted
Black Belt
110 Views

There is nothing you can do

There is nothing you can do in the DLL to affect the stack size. My advice is to build the DLL with /heap-arrays enabled.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
110 Views

I am using a set of

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 .

0 Kudos
Highlighted
110 Views

>>When I enable /heap-arrays

>>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.

Jim Dempsey

0 Kudos
Highlighted
110 Views

If you enable /heap-arrays >

If you enable /heap-arrays > 0.  Do you have to set the size allocation for the heap anywhere else?

0 Kudos
Highlighted
110 Views

To track errors, look at

To track errors, look at additional environment variables

https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-supported-environmen...

Jim Dempsey

0 Kudos
Highlighted
Black Belt
110 Views

Do not set the value of /heap

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.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos