It was thus said that the Great Chuck McManis once stated:
At 09:37 PM 8/22/01 -0400, Sean wrote:
I just compiled the C hello world program under
Linux 2.2.12 with
egcs-2.91.66 and got the following:
-rwxrwxr-x 1 spc spc 932131 Aug 22 21:32 hello
Okay, granted, I compiled it statically (if I compiled normally, it would
be 11,811 bytes in size 8-) but still, nearly a megabyte there!
So what's your point? How much memory do you have on this machine? What
fraction of main memory is 932,131 bytes? Given dynamic linking, what
fraction is 11,811 bytes?
Depending upon the system I run the executable on, 932,131 is anywhere
from 1/4 to 1/32 of the memory (my laptop running Linux
has 4M of RAM, while
my main development machine has 32M RAM). I'll leave the
11,811 bytes as an
exercise 8-)
Here's another test (which is actually useful.)
compare the difference between
main() {
printf("Hello World.\n");
}
and
main() {
printf("Hello World.\n");
}
Is there a difference?
or even more importantly
main() {}
What is the incremental cost of computation once you get into the game?
I did
#include <stdlib.h>
int main(void) { return(EXIT_SUCCESS); } /* [1] */
A static link made a binary of 435,031 bytes, and dynamically linking is
around 3k (using the default options). So that's the overhead (at least
under RedHat 5.2).
-spc (Still a bit large to me ... )
[1] The smallest ANSI-C conformant program. I can't stand K&R C 8-)