From: boone@athena.cs.uga.edu (Roggie Boone)
Newsgroups: comp.sys.ibm.pc.programmer,comp.lang.c
Subject: TC/C++ Out of memory error -- Please help!
Date: 6 Oct 92 17:17:31 GMT
Distribution: usa
Organization: University of Georgia, Athens

[I posted this to comp.compilers but the moderator suggested that
 I post to this group also.]

I am receiving an "Out of Memory" fatal error while compiling a
C++ program in Turbo C/C++.  It is very strange though.  The program
is not that big -- the source file is only about 31K (and the EXE from
an earlier compile was only 68K).  I include <iostream.h>, <fstream.h>
<iomanip.h> and < dos.h>.  There is nothing fancy going on 
in the program.  It consists mostly of if..else statements then a
bunch of "cout" (ie. printf()) statements.

I have a computer with 640K conventional (of which 613K is available for
executing programs) and I have also configured my machine to provide
6MB of expanded memory.  I have tried compiling inside the IDE and
from the command line with "TCC -Qe myprog.cpp" where "-Qe" means
to use all available expanded memory.  I don't think the compiler is
using the expanded memory because I get the same out of memory error
whether I have 6MB EMS configured or not.

If you can help in any way based on what was said above, I would very
much appreciate it.  If you want more details about the program and/or
what I have tried thus far, then read on (below the signature).

Roggie Boone
Computer Support Staff                    Internet:  boone@athena.cs.uga.edu     
Dept. of Ag and Applied Economics         Internet:  roggie@aisun1.cs.uga.edu
University of Georgia                     Phone:  (706) 542-2482

--------------------------  Additional Info ------------------------
The program is actually very simple.  All I want it to do is read
some data from a file and based on the data read, update cells in
a 29x11 array of longs.  I do this with about 28 if..else statements.
I then want to print out the contents of the array.  
Again, I do this with about 28 "cout" statements based on
certain conditions.  Nothing fancy.

Originally, I did not use an array, but instead had about 300 global
variables of type int.  The program compiled fine.  I then changed
the _TYPE_ of those 300+ variables from "int" to "long" and then
I got the out of memory error!!!  That struck me as odd, but I don't
know the internal workings of the compiler.  So I decided to create
an array to hold the variables instead of having 300+ individual 
variables.  I still got the error message.

The compiler runs out of memory about 10 lines from the bottom of the
program.  I can comment out those last 10 lines and it compiles fine.
That is when I have my computer configured for 640K conventional and
7MB XMS and I am compiling inside the IDE.

When I reconfigure the computer to have 6MB EMS memory, and compile
inside the IDE or with the line "tcc -Qe myprog.cpp", there is no
difference.





-- 
Roggie Boone
Computer Support Staff                    Internet:  boone@athena.cs.uga.edu     
Dept. of Ag and Applied Economics         Internet:  roggie@aisun1.cs.uga.edu
University of Georgia                     Phone:  (706) 542-2482
Newsgroups: comp.sys.ibm.pc.programmer,comp.lang.c,comp.lang.c++