From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,cea30133e185dc3 X-Google-Attributes: gid1014db,public X-Google-Thread: fee84,cea30133e185dc3 X-Google-Attributes: gidfee84,public From: kaz@cafe.dot.net (Kaz Kylheku) Subject: Re: How do you release memory back to the kernel in C Date: 1998/05/19 Message-ID: <35620a04.2342689789@207.126.101.81>#1/1 X-Deja-AN: 354765194 References: <35616C36.9167165F@citicorp.com> Reply-To: kaz@cafe.net X-Complaints-To: newsabuse@supernews.com X-Trace: 895617359 8EGGZV7/GD230CCEFC usenet57.supernews.com Organization: Infowave Wireless Messaging Inc. Newsgroups: comp.unix.osf.osf1,comp.lang.c On Tue, 19 May 1998 12:25:42 +0100, Asgar Ali wrote: >In DEC Unix (3.x and 4.x) I am finding that "free" does not release >memory back to the kernel so that it could be used by other processes. See Peter Seebach's Infrequently Asked Questions list: 6.9: I have a program which mallocs but then frees a lot of memory, but memory usage (as reported by ps) doesn't seem to go back down. You're probably not freeing the memory completely. Try replacing free(foo); with free(foo); free(foo); free(foo); in case the first free() frees the memory only partially. (Unix wizards may recognize the parallel with syncing three times before rebooting.) Alternatively, free(foo) + 4; may free the remaining four bytes. (Before using this, make sure realloc(foo, 0) returned 4).