From owner-freebsd-questions Wed May 10 23:50:35 2000 Delivered-To: freebsd-questions@freebsd.org Received: from lince.tdnet.com.br (lince.tdnet.com.br [200.236.148.6]) by hub.freebsd.org (Postfix) with ESMTP id 1C9D037B699 for ; Wed, 10 May 2000 23:50:26 -0700 (PDT) (envelope-from kernel@tdnet.com.br) Received: from tdnet.com.br [200.236.148.146] by lince.tdnet.com.br with ESMTP (SMTPD32-5.00) id AA1B272A00E6; Thu, 11 May 2000 02:50:19 -0300 Message-ID: <391A2CC2.383E1BCE@tdnet.com.br> Date: Thu, 11 May 2000 03:45:06 +0000 From: Gustavo Vieira Goncalves Coelho Rios X-Mailer: Mozilla 4.72 [en] (X11; I; FreeBSD 4.0-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: small program is eating my memory. Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 #include #include 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