PRB: Fatal Error C1002: Out of Heap Space in Pass 2

ID Number: Q65702

6.00 6.00a 6.00ax 7.00 | 6.00 6.00a

MS-DOS | OS/2

Summary:

SYMPTOMS

In Microsoft C versions 6.0, 6.0a, and 6.0ax, fatal error c1002 is

produced when pass 2 of the compiler (C2.EXE) can find no more

memory available to store information that is needed to continue

compiling. This information typically consists of defined

variables, function names, and temporary information used when

evaluating complex expressions. Information used for optimizing may

even use dynamic memory, which can cause this error to occur.

RESOLUTION

One of the following may be a solution:

1. Divide the source file into smaller source files. This provides

many advantages, including the following:

a. It reduces compiling time for small changes in a program.

b. It allows the functions to be separated from the program so

they may be used by other programs.

c. The .OBJs may be placed into a library.

d. Placing code in separate files may aid in readability because

the developer does not need to search through large files.

2. Break complex expressions into smaller subexpressions. Using

temporary variables for intermediate assignments is an example.

This can also help with program readability.

3. If using OS/2, recompile using the /B2 C2L.EXE option. This

invokes the high-capacity compiler (C2L.EXE) on the second pass

of the compiler. C2L.EXE may cause a longer compiling time and

should not be used if not needed.

4. If running any TSRs (terminate-and-stay-resident programs) or

device drivers, try removing these to free more memory. The

compiler does not take advantage of extended or expanded memory,

so try to free as much of the 640K conventional memory as

possible.

5. If using NMAKE, MAKE, or other program building utilities, try

compiling without them. These programs reside in memory when

your compiler is invoked. If using MS-DOS, try running NMK.COM

rather than NMAKE.EXE. (Refer to the online help for differences

between NMK.COM and NMAKE.EXE.)

6. Observe the compiling options. Change these to see if these have

any affect. For example, disable optimizations with /Od if

optimizing is currently enabled.

7. If you are currently using version 6.0, and haven't yet

installed the upgrade to 6.0ax, do the following:

a. Install the upgrade by running SETUP.EXE from the disk

labeled "Supplemental Tools." This disk is shipped with

version 6.0 of the compiler. If you do not have this disk,

contact Microsoft Customer Service to order the Microsoft

C upgrade to version 6.0b.

b. Add the /EM option to the command line for compilation. This

will invoke an MS-DOS extended version of Microsoft C version

6.0a.

Additional reference words: 6.00 6.00a 6.00ax 7.00