PRB:R6009 Not Enough Space for Environment Possible Workaround

ID Number: Q50714

5.00 5.10 6.00 6.00a 6.00ax 7.00

MS-DOS

Summary:

SYMPTOMS

In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, 6.0ax, and C/C++

version 7.0, the following error message may be generated:

R6009: Not Enough Space For Environment

CAUSE

The "R6009: Not Enough Space For Environment" run-time error is

caused when a program successfully loads into memory and then

attempts to load a copy of the environment and the argument list

into the near heap. If the near heap does not have enough room for

one, the other, or both, R6009 is generated.

RESOLUTION

The following are four ways to work around the problem:

1. Lower the amount of environment space with the following

statement in the CONFIG.SYS file. This assumes that environment

space is being allocated.

shell=command.com /p /e:xxxx

-or-

2. When compiling, use the large memory model in conjunction with

the /Gt switch to get some of the global data out of DGROUP,

thus freeing up room for the environment and/or the argument

list. (/Gt3 is a good place to start.)

-or-

3. If there is no need for command-line arguments, _setargv() can

be rewritten as follows:

_setargv() {}

-or-

4. If there is no need for a copy of the environment, and if the

spawn or exec functionality is not needed, _setenvp() can be

rewritten as follows:

_setenvp() {}

More Information:

In standard Microsoft C programs, the functions _setargv() and

_setenvp() attempt to set up the argument vector and the environment

vector, respectively. Both of these vectors are allocated in the near

heap. If the program has a full or nearly full near heap, the vectors

will not be set up, thereby giving the error.

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00 s_quickc