- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've converting a Fortran 77 code that has lots of stack memory utilization from an executable to a DLL (Windows). For example there are hundreds (thousands) of arrays such as this:
COMMON/A1/ CU1(LCM,KCM), CU2(LCM,KCM), 2 UUU(LCM,KCM), VVV(LCM,KCM), WWW(LCM,0:KCM), 3 DU(LCM,KCM), DV(LCM,KCM), 4 FX(LCM,KCM), FY(LCM,KCM)
After modifying the stack reserve size to be as large as possible the program compiles and runs as a standalone executable. When it's compiled as a DLL it crashes with:
Unable to load DLL 'LIB.dll': Not enough storage is available to process this command. (Exception from HRESULT: 0x80070008)
What is the difference in a DLL and EXE that is causing this?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Common block things are normally (perhaps always) statically allocated, not stack allocated.
I don't think the stack reserve setting for a DLL is used at all - the settings for the initial thread (and I think subsequent threads that specify a default stack size) are always taken from the executable file for the process
I suspect that the static allocation required by the DLL is simply too large to fit in the available gaps in the process address space once your exe (including its stack), and all the other DLL's that typically get loaded, has been laid out in memory.
Are you compiling for 32 bit Windows? 64 bit windows removes many of the limitations in this area, but not all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ian is correct that setting stack size in a DLL does nothing. This is an EXE property only. As Ian suggests, the problem is more likely to be static allocation snd insufficient address space. Note that there is a practical limit of 1.75GB or so for static code and data, even in a 64-bit application (on Windows).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This information is great. However, I've changed the static allocation size to be very small (at least by changing the variable size) and the application is still unable to load the DLL with the same error. I also modified the target EXE to increase the stack reserve size also without effect (an interesting side effect was that as I increased the stack reserve size with editbin /stack the application became gradually slower and unresponsive).
Is there an easy way to determine the static allocation size during the compilation and linking process?
The Fortran DLL is being loaded into a .Net application. Are you aware of anything in this interaction that would cause the issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you ask for a link map, you can get the static size from that. But I am going to guess that this isn't the real problem - it is something in the .NET environment that is not working properly.

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