From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,cea30133e185dc3 X-Google-Attributes: gidfee84,public X-Google-Thread: 1014db,cea30133e185dc3 X-Google-Attributes: gid1014db,public From: fred@genesis.demon.co.uk (Lawrence Kirby) Subject: Re: How do you release memory back to the kernel in C Date: 1998/05/19 Message-ID: <895607898snz@genesis.demon.co.uk>#1/1 X-Deja-AN: 354747832 References: <35616C36.9167165F@citicorp.com> X-Mail2News-Path: news.demon.net!genesis.demon.co.uk Reply-To: fred@genesis.demon.co.uk X-Complaints-To: abuse@demon.net X-Trace: mail2news.demon.co.uk 895613992 mail2news:29088 mail2news mail2news.demon.co.uk Organization: none 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. On a VM system unused memory teds to get moves to swap space. As long as you don't run out of swap space it may not be a big problem. >I have a simple program below which illustrates the problem. >The program allocates 10Mb, then another 10Mb, then frees the second, >then frees the first. Both frees do not release the memory back to >kernel, though the same process could reuse its free memory. That is typical. The C language doesn't require that freed memory be released in this way, indeed it provides no answer to your question. You could try finding a replacement malloc() library that does what you want or try to find some platfor-specific alternative. For example many Unix platforms these days support a mmap() system function which may well provide a solution. -- ----------------------------------------- Lawrence Kirby | fred@genesis.demon.co.uk Wilts, England | 70734.126@compuserve.com -----------------------------------------