This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
(C++) High memory usage with templates
- To: egcs at cygnus dot com
- Subject: (C++) High memory usage with templates
- From: chrisb at sandy dot force9 dot co dot uk (Chris Butler)
- Date: Sun, 29 Nov 1998 21:29:05 +0000 (GMT)
Hi,
In addition to my previous message, here is a short program that
demonstrates this behaviour.
== start memory-test.cc ==
//
// Demonstrate the high memory usage when compiling with templates
//
// With -O2 turned on, cc1plus uses about 10megs compiling
// this. Without optimisation, it uses about 6megs.
#include <vector>
#include <map>
#include <string>
int main()
{
typedef map<string, unsigned short> myMap;
typedef vector<myMap> someMaps;
myMap fred, barney;
someMaps wilma;
fred.insert(pair<string, unsigned short>("foo", 1));
fred.insert(pair<string, unsigned short>("bar", 2));
barney.insert(pair<string, unsigned short>("foo", 2));
barney.insert(pair<string, unsigned short>("bar", 1));
wilma.push_back(fred);
wilma.push_back(barney);
}
== end memory-test.cc ==
--
Chris Butler
<chrisb@sandy.force9.co.uk>