Code optimization vs. memory usage
Erik Ljungström
erik@ibiblio.org
Fri Feb 6 10:57:00 GMT 2004
Hi!
I have got a source file with 1386 lines of standard C++ code.
When I'm compiling this with -O1 and -O2, the memory usage rises to
~120 MB, and the compilation takes 1 minute 40 seconds.
When I compile the same file without optimization, the memory usage is
barely worth mentioning, and the compilation is done in roughly 2.5
seconds.
I have put the code on-line if it helps anyone, and it's available at:
http://northernmost.org/fork.cpp
Now, I wonder if this is normal? What kind of functions generates this
difference? The code is pretty much straight forward, without gotos and
similar things. It do however, contain quite a few if-statements. Are
there anything I could do to reduce the memory usage upon compiling?
I suppose I will have to break the file into several smaller ones?
This is quite a tough issue, since most FreeBSD users has optimization in
their make.conf, and the file needs at the very least 128 mb of memory to
compile.
I have tried to compile the code on gcc 3.2.3 as well as 3.3.2 under Linux
and NetBSD with the same result.
Thanks in advance!
--
Erik Ljungström
erik@ibiblio.org
http://northernmost.org/~erik/
Storuman, Sweden
More information about the Gcc-help
mailing list