From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,79b248c1cf206957,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-04 08:14:23 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!news.tele.dk!small.news.tele.dk!128.39.3.168!uninett.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: Why is memory footprint smaller when compiled static? Date: Tue, 4 Jun 2002 15:14:22 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: NNTP-Posting-Host: kiuk0156.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1023203662 23781 129.241.83.82 (4 Jun 2002 15:14:22 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Tue, 4 Jun 2002 15:14:22 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:25307 Date: 2002-06-04T15:14:22+00:00 List-Id: I compiled my application (a GtkAda program) on Linux first as: gnatmake glosa -O3 `gtkada-config -static` -bargs -static then as gnatmake glosa -O3 `gtkada-config` I stripped both executables afterwards (as I forgot the -s flag) The executable sizes becomes: 2583572 bytes for the static version 752060 bytes for the dynamic version When I run the two programs and examine the memory usage of the two programs I find : 3296 kb for the static version 4412 kb for the dynamic version Why is there such a big difference? Is it because the compiler can do better job at optimising the code when you build it statically. I also did the same without the -O3 switch and then the memory usage was: 3412 kb for the static version 4512 kb for the dynamic version Preben who knows very little on how compilers work