- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I use ifort11 to compile the windows application. Recently I figureout that, stacksize limitatation is causing some error and with /F option, I could overcome for the time being. But my objective is to set the unlimited stacksize or auto stacksize based on the operating system (my application will be used in 32- as well as 64- bit machines).
Can someone advise me on how to make unlimited or auto stack size for windows?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Even on 64-bit Windows, the stack is limited to 2GB (along with static code and data). I recommend setting the option Optimization > Heap Arrays > 0 (/heap-arrays) if you have problems with running out of stack. Keep in mind that setting the stack reserve size very large may prevent the program from running at all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Sergey and Steve.
Setting more than 2GB limit worked on Win 7 x64 workstation, but not on Win XP x64 workstation. However, when I reduced to 1GB, it works everywhere.
@ Steve - Do you think, setting 2GB stack size will be the best or 1GB would be the optimal consider other processes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>> or 1GB would be the optimal consider other processes?
The stack size comes out of your Virtual Machine address space (per thread). The system resources taken (pages in page file) do not occur until a location within the Virtual Address page is referenced. Unused stack space consumes no system resource (but does consume virtual address space from the application). On x32 application, loss of virtual address space for (unwarrentedly large) stack space (per thread) eats into available heap space. If you are programming multi-threaded, as x32 app, program for more heap usage than stack usage (e.g. enable heap arrays) to reduce stack requirements, and then determine worst case stack requirement and set stack size to worst case + nn%.
"Unlimited" stack size is a meaningless term. Truely unlimited stack size would be infinite. Impractical unlimited stack size would be all of virtual address space (no remaining memory for code nor heap). While you could have heap start at lower virtual address (above code) and creap up in virtual address as heap requirements grow, and stack creap down from top usable virtual address (below O/S reserved space), this technique is only valid for single threaded application. On multi-threaded you have a issue of how to partition the gap between top of code and static data and beginning of first stack (each thread has its own stack as part of flat address space of application). For x64 application, you can specify multi-GB if you desire (unless you have 1000's of threads), but on x32 application you have to be careful as virtual address space is a (practical) limited resource.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do not try setting 2GB as a stack size. It will give you problems. Please use /heap-arrays to reduce the use of stack.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Simpler question: how do I set the stack size when using VS2010 with intel fortran. Searching the help agent with the query stack linker option setting size of' came up with nothing related to fortran. Please let me know. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is not Fortran specific - it is something set by the linker. See http://msdn.microsoft.com/en-us/library/8cxs58a6%28v=vs.100%29.aspx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's the "Stack Reserve Size" you want to set under Linker > System. Or consider setting Fortran > Optimization Heap Arrays to 0. This will free you from worrying about the stack in most cases.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page