virtual memory exhausted
Issac Alphonso
alphonso@isip.msstate.edu
Thu Nov 23 09:52:00 GMT 2000
I sent this message out before but this time I have also included a
pointer to the .ii preprocessed C++ files:
http://www.isip.msstate.edu/~alphonso/misc/
I know that you don't accept URL's but I have tried sending the .ii
files as an attachments only for the mail to bounce because the .ii
file are too large:
<gcc-bugs@gcc.gnu.org>:
ezmlm-reject: fatal: Sorry, I don't accept messages larger than 200000 bytes (#5.2.3)
I *urgently* require a resolution on why the gcc compiler runs out of
virtual memory during compilation and was hoping you could make and
exception this time. Thanks.
Description:
------------
I have encountered a nasty problem when compiling a List class that I am
trying to write. The List class uses a virtual pointer that can be
initialized to either a single or a double linked list via polymorphism.
When I declare multiple instances of the List class in a function and
perform several operations on it the virtual memory used in compiling
the function keeps on increasing until the compile job dies.
For some reason as the number of List class instances and operations
on those List class instances grows in the function so does the
memory needed for the compile job. Eventually the compile job dies
saying that the "virtual memory has been exhausted."
Also, the problems with the compile job dying only occurs when I
optimize the code using the -O2 flag (using gcc version 2.95.2).
I would appreciate any pointers especially if someone has
encountered a similar problem like this before.
GCC version:
-----------
gcc version 2.95.2 19991024 (release)
Systems info:
-------------
i386-pc-solaris2.7
sparc-sun-solaris2.6
i386-pc-redhat-linux6.2
Command line:
-------------
gcc -o ListDiagnose_diag.o -I/isip/d108/alphonso/tools/include -Wall
-ftemplate-depth-50 -DTEMPLATE_DIAGNOSE -include
/isip/d108/alphonso/tools/class/dstr/List/ListDiagnose.h
-DDIAG_CLASS_NAME=ListDiagnose<Char> -O2 -c diagnose_class.cc
Compiler output:
----------------
isip108_[1]: make OPTIMIZE=-O2 DEBUG=-save-temps test
> checking header dependencies for List.h ListBase.h
> linking /isip/d108/alphonso/tools/class/dstr/List/List.h to
/isip/d108/alphonso/tools/include/List.h
> linking /isip/d108/alphonso/tools/class/dstr/List/ListBase.h to
/isip/d108/alphonso/tools/include/ListBase.h
> skipping install
creating diagnostic program for ListDiagnose in directory
/isip/d108/alphonso/tools/class/dstr/List
make[1]: Entering directory
`/isip/d108/alphonso/tools/util/devel/diagnose_class'
> removing objects and binary ListDiagnose.exe
gcc -o ListDiagnose_diag.o -I/isip/d108/alphonso/tools/include -Wall
-ftemplate-depth-50 -DTEMPLATE_DIAGNOSE -include
/isip/d108/alphonso/tools/class/dstr/List/ListDiagnose.h
-DDIAG_CLASS_NAME=ListDiagnose<Char> -O2 -save-temps -c diagnose_class.cc
/isip/d108/alphonso/tools/class/dstr/List/ListDiagnose.h: In function
`static boolean ListDiagnose<Char>::diagnose(Integral::DEBUG)':
diagnose_class.cc:48: instantiated from here
/isip/d108/alphonso/tools/class/dstr/List/ListDiagnose.h:3753: virtual
memory exhausted
make[1]: *** [ListDiagnose_diag.o] Error 1
gcc -I/isip/d108/alphonso/tools/include -Wall -ftemplate-depth-50
-DTEMPLATE_DIAGNOSE -include
/isip/d108/alphonso/tools/class/dstr/List/ListDiagnose.h
-DDIAG_CLASS_NAME=ListDiagnose<Char> -O2 -save-temps -c diag_param_00.cc
make[1]: Target `install' not remade because of errors.
make[1]: Leaving directory
`/isip/d108/alphonso/tools/util/devel/diagnose_class'
make: *** [ListDiagnose.exe] Error 2
Sample Code:
------------
enum LIST_TYPE { SINGLE = 0, DOUBLE, DEF_LIST_TYPE = DOUBLE };
// virtual class interface
template<class T>
class ListBase {
virtual boolean add() = 0;
virtual boolean remove(T* obj) = 0;
...
...
}
template<class T>
class List {
// virtual pointer
ListBase<T>* virtual_lst_d;
// constructor
List (LIST_TYPE arg = DEF_LIST_TYPE) {
if (arg == SINGLE) {
virtual_lst_d = new SingleLinkedList<T>();
}
else {
virtual_lst_d = new DoubleLinkedList<T>();
}
}
// call through methods for add
boolean add() {
virtual_lst_d->add();
}
// call through methods for remove
boolean remove(T* obj) {
virtual_lst_d->remove(obj);
}
...
...
}
template<class T>
class SingleLinkedList : public ListBase<T> {
boolean add();
boolean remove(T* obj);
...
...
}
template<class T>
class DoubleLinkedList : public ListBase<T> {
boolean add();
boolean remove(T* obj);
...
...
}
--
Issac Alphonso <ija1@ece.msstate.edu> < http://www.ece.msstate.edu/ >
Mississippi State University, Mississippi 39762
More information about the Gcc-bugs
mailing list