comp.lang.ada
 help / color / mirror / Atom feed
* Why is memory footprint smaller when compiled static?
@ 2002-06-04 15:14 Preben Randhol
  2002-06-04 16:13 ` Mark Johnson
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Preben Randhol @ 2002-06-04 15:14 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: Why is memory footprint smaller when compiled static?
@ 2002-06-05 11:37 Grein, Christoph
  2002-06-05 12:36 ` Preben Randhol
  0 siblings, 1 reply; 22+ messages in thread
From: Grein, Christoph @ 2002-06-05 11:37 UTC (permalink / raw)


> > 
> >> Why is there such a big difference?
> > 
> > Page granularity?  Space taken by the GOT?  Overhead of
> > position-independent code?
> 
> Can one have page granularity resulting in 1 Mb difference? The two
> others I don't understand what is.

This is a qustion that appears every now and then. In my eyes, it's rather 
pointless to argue about Hello_World size. Real programs matter, and there the 
differences are minor if programs are really comparable (proper setting of 
options).

The difference in size normally can be attributed to differences in the IO parts 
of C and Ada: Ada does many more things than C, so IO is not comparable, and IO 
is all that matters in Hello_World.



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2002-06-11 21:38 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-04 15:14 Why is memory footprint smaller when compiled static? Preben Randhol
2002-06-04 16:13 ` Mark Johnson
2002-06-04 21:01 ` Florian Weimer
2002-06-04 21:02 ` Florian Weimer
2002-06-04 21:03 ` Florian Weimer
2002-06-05 11:10   ` Preben Randhol
  -- strict thread matches above, loose matches on Subject: below --
2002-06-05 11:37 Grein, Christoph
2002-06-05 12:36 ` Preben Randhol
2002-06-05 13:42   ` Mark Johnson
2002-06-06  0:02   ` Steven Deller
2002-06-06 10:35     ` Preben Randhol
2002-06-06 14:26     ` Gautier
2002-06-06 15:08       ` Jean-Marc Bourguet
2002-06-06 15:24         ` Jean-Pierre Rosen
2002-06-06 19:35           ` Jeffrey Carter
2002-06-10 23:51     ` Randy Brukardt
2002-06-11  0:53       ` Robert A Duff
2002-06-11 16:45         ` Wes Groleau
2002-06-11 17:08           ` Preben Randhol
2002-06-11 19:12             ` Wes Groleau
2002-06-11 21:38               ` Randy Brukardt
2002-06-11 21:32         ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox