Microsoft KB Archive/63382

= PRB: R6009: &quot;Not Enough Space for Environment&quot; When Heap Full =

Article ID: 63382

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.01
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q63382



SYMPTOMS
An attempt to run an application fails and the following message appears on the screen:

R6009: Not Enough Space For Environment



CAUSE
After the application loads into memory, this error occurs when the application is unable to load a copy of the environment and the argument list into the near heap.



RESOLUTION
To work around this problem, perform one of the following four steps:

  If the CONFIG.SYS file contains a SHELL statement with the /e: parameter, reduce the amount of environment space SHELL allocates by reducing the value specified in the /e: parameter. The SHELL statement should somewhat resemble the following:      shell=c:\command.com /p /e:xxxx -or-

 Compile the application with the large memory model. Specify the /Gt compiler option switch to remove some global data from the DGROUP default data segment and free memory for the environment and the argument list. (The /Gt0 compiler option switch removes the most data from DGROUP.) -or-

 If the application does not use any command-line arguments, rewrite the C function _setargv to do nothing. If the application does not need a copy of its environment, rewrite the C function _setenvp. The code example below demonstrates eliminating these two C functions in FORTRAN. -or-

 Reduce the stack size to provide room for the command-line arguments and the environment.



MORE INFORMATION
In an application developed in standard Microsoft C, the _setargv and _setenvp functions attempt to set up the argument vector and the environment vector, respectively. Each of these vectors is allocated from the near heap. In the near heap is full, or nearly full, the functions are unable to set up the vectors and the R6009 run-time error occurs.

To prevent the error, substitute a null function for the _setargv and _setenvp functions to prevent the near heap allocation from taking place. The following FORTRAN code example performs this task. Specify the /NOE linker option switch to prevent the &quot;L2044: symbol multiply defined&quot; error.

Sample Code
C Compile options needed: None

INTERFACE TO SUBROUTINE SETARGV[C, ALIAS:'__setargv'] END INTERFACE TO SUBROUTINE SETENVP[C, ALIAS:'__setenvp'] END SUBROUTINE SETARGV RETURN END SUBROUTINE SETENVP RETURN END

Additional query words: 4.00 4.01 4.10 5.00 5.10

Keywords: KB63382

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.