Date: Thu, 11 May 2000 03:45:06 +0000 From: Gustavo Vieira Goncalves Coelho Rios <kernel@tdnet.com.br> To: freebsd-questions@freebsd.org Subject: small program is eating my memory. Message-ID: <391A2CC2.383E1BCE@tdnet.com.br>
next in thread | raw e-mail | index | archive | help
While playing a little bit with C, i realized that even small C programs eat too much memory. May you, kindly, explaim me what is happenning? How can i optimize it? I think here is eating too much memory. a.c listing.... #include <stdio.h> #include <unistd.h> #include <string.h> enum { T_SLICE = 10000 }; int main(int argc, char *argv[]) { unsigned int c; unsigned int d; unsigned int v; if (!*++argv) { printf("usage: %s <1/100 seconds>\n", *--argv); fflush(stdout); return 1; } v = atoi(*argv); c = 0x7c2f2d5c; d = 0x7c5c2d2f; printf("Useless program (by grios): ...%c", c); fclose(stdin); fclose(stderr); for (;;) { c = c << 8 | c >> 24; printf("\b%c", c); fflush(stdout); usleep(v * T_SLICE); } return 0; } ---end listing a.c How did i compiled: cc -ansi -pedantic -Wall -s a.c after running it, here is what i got: $ ps aux | grep a.out grios 90285 0.0 0.4 816 448 p1 SN+ 3:42AM 0:00.16 ./a.out 1 It resident size is about 816K and is resident around 448! Why such a small program eats so much memory? Thank you for your time and cooperation. -- "Sometimes I worry about being a success in a mediocre world." -- Lily Tomlin To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?391A2CC2.383E1BCE>