From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 19 Jul 2003 18:34:50 +0500 From: "Vinay I K" Message-ID: Mime-Version: 1.0 Reply-To: abcxyz1@lycos.com Subject: Linux free issue Content-Type: text/plain; charset=us-ascii Content-Language: en Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: Linux-MM@kvack.org List-ID: Hello, Its a newbie question. I have been trying to look around and hit upon the following link. http://mail.nl.linux.org/linux-mm/1998-08/msg00028.html I am a bit confused. When we call free in Linux, is the memory not given back to the system(just cached)? What is the state of the issue in the latest Linux Kernel? Thanks, Vishwas ____________________________________________________________ Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail! http://login.mail.lycos.com/r/referral?aid=27005 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: aart@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 19 Jul 2003 18:35:12 +0500 From: "Vinay I K" Message-ID: Mime-Version: 1.0 Reply-To: abcxyz1@lycos.com Subject: Linux free issue Content-Type: text/plain; charset=us-ascii Content-Language: en Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: Linux-MM@kvack.org List-ID: Hello, Its a newbie question. I have been trying to look around and hit upon the following link. http://mail.nl.linux.org/linux-mm/1998-08/msg00028.html I am a bit confused. When we call free in Linux, is the memory not given back to the system(just cached)? What is the state of the issue in the latest Linux Kernel? Thanks, V ____________________________________________________________ Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail! http://login.mail.lycos.com/r/referral?aid=27005 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: aart@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 19 Jul 2003 10:39:04 -0400 (EDT) From: Rik van Riel Subject: Re: Linux free issue In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org Return-Path: To: Vinay I K Cc: Linux-MM@kvack.org List-ID: On Sat, 19 Jul 2003, Vinay I K wrote: > http://mail.nl.linux.org/linux-mm/1998-08/msg00028.html > > I am a bit confused. When we call free in Linux, is the memory not given > back to the system(just cached)? What is the state of the issue in the > latest Linux Kernel? The issue is not in the Linux kernel at all, but in glibc. It is the C library that has (after careful measuring and optimising) made the decision to not call the system call to free memory but instead keep it for later use. I suspect their decision is the right one in most of the cases. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: aart@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sun, 20 Jul 2003 10:27:43 +0800 From: Eugene Teo Subject: Re: Linux free issue Message-ID: <20030720022743.GD16983@eugeneteo.net> Reply-To: Eugene Teo References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org Return-Path: To: Rik van Riel Cc: Vinay I K , Linux-MM@kvack.org List-ID: > On Sat, 19 Jul 2003, Vinay I K wrote: > > > http://mail.nl.linux.org/linux-mm/1998-08/msg00028.html > > > > I am a bit confused. When we call free in Linux, is the memory not given > > back to the system(just cached)? What is the state of the issue in the > > latest Linux Kernel? > > The issue is not in the Linux kernel at all, but in glibc. > It is the C library that has (after careful measuring and > optimising) made the decision to not call the system call > to free memory but instead keep it for later use. I agree with Riel. It has nothing to do with the kernel, but the implementation of the dynamic memory allocator in the userspace C library. The actual implementation might differ a little but the general idea is that whenever you do a free, it deallocates the region of memory by storing this "freed" space to a free list. You will notice that the heap offset is not decreased by using the sbrk syscall. The next time you call malloc, it will search through the free list, and if a space matches, that spaces will be used to your program. Otherwise, it will increase the heap, allocate a region of memory you specified for your program instead. Eugene -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: aart@kvack.org