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: john@iastate.edu (John Hascall) Subject: Re: How do you release memory back to the kernel in C Date: 1998/05/21 Message-ID: <6k208g$ajq$1@news.iastate.edu>#1/1 X-Deja-AN: 355327960 References: <35616C36.9167165F@citicorp.com> <895607898snz@genesis.demon.co.uk> Organization: Iowa State University, Ames, Iowa USA Newsgroups: comp.unix.osf.osf1,comp.lang.c }In article <35616C36.9167165F@citicorp.com> } asgar.ali@citicorp.com "Asgar Ali" writes: }>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. }>This creates the problem that if several such processes are running each }>needed a lot of memory at some time, none of them can share what the }>others have used. Hence you run out of memory quickly. >From 'man malloc' (DU 4.0d): Tuning Memory Allocation The behavior of these memory allocation functions can be tuned to optimize their performance in a particular application. The following variables control how the functions operate. Note that these variables and their effects are specific to the current DIGITAL UNIX memory allocation implementation. The default values for these variables are specified by libc. To specify values other than the defaults, create a module containing definitions for the complete set of variables and include that module in your compilation. (If you define only some of these vari- ables, your compilation will produce "multiply defined" errors if you link the program nonshared.) For each variable in this list, the default value is indicated after the equal sign. unsigned long __noshrink = 0 The variable __noshrink controls management of the heap size (which in turn controls the size of the required swap area). As the user makes calls to free() or realloc(), the memory associated with the call can be put back into the pool of free memory. Permissible values for __noshrink are 0 and 1. If the memory that is freed resides at the end of the heap and meets the constraints of __minshrink and __minshrinkfactor, it can be returned to the kernel by sbrk(nnn) if __noshrink is 0. If __noshrink is 1, no attempts are made to return the freed memory. John -- John Hascall, Software Engr. Shut up, be happy. The conveniences you ISU Computation Center demanded are now mandatory. -Jello Biafra mailto:john@iastate.edu http://www.cc.iastate.edu/staff/systems/john/welcome.html <-- the usual crud