From owner-freebsd-hackers Sun Sep 21 16:06:05 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id QAA23618 for hackers-outgoing; Sun, 21 Sep 1997 16:06:05 -0700 (PDT) Received: from ns.mt.sri.com (SRI-56K-FR.mt.net [206.127.65.42]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id QAA23600 for ; Sun, 21 Sep 1997 16:05:57 -0700 (PDT) Received: from rocky.mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by ns.mt.sri.com (8.8.7/8.8.7) with ESMTP id RAA07320; Sun, 21 Sep 1997 17:05:47 -0600 (MDT) Received: (from nate@localhost) by rocky.mt.sri.com (8.7.5/8.7.3) id RAA28148; Sun, 21 Sep 1997 17:05:46 -0600 (MDT) Date: Sun, 21 Sep 1997 17:05:46 -0600 (MDT) Message-Id: <199709212305.RAA28148@rocky.mt.sri.com> From: Nate Williams MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Eivind Eklund Cc: Nate Williams , Eivind Eklund , phk@critter.freebsd.dk, hackers@freebsd.org Subject: Re: Bug in malloc/free (was: Memory leak in getservbyXXX?) In-Reply-To: <19970922005506.48602@bitbox.follo.net> References: <199709182202.PAA10664@hub.freebsd.org> <199709211737.TAA20833@bitbox.follo.net> <199709212247.QAA28054@rocky.mt.sri.com> <19970922005506.48602@bitbox.follo.net> X-Mailer: VM 6.29 under 19.15 XEmacs Lucid Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > > > >From what I can tell Poul your free() actually gives the memory back to the > > > > OS ( at least some of the time ). > > > > > > If this is correct, it breaks ANSI C behaviour. > > > > Huh? I didn't realize ANSI mandated OS support. Can you quote chapter > > and verse that says this? > > It doesn't. However, it has a formulation that IMHO is too > restrictive - that free() 'makes the memory available for further use > by the program' (from memory). Thus, an implementation of > malloc()/free() that give memory back to the OS is in violation of the > standard. Depends on how you interpret the standard. If you give it back to the OS, you can always(*) get it back at a later time. So, the 'memory' is still available by the program. :) Nate * - It's possible, but highly improbably that if the system is very low on memory that the program won't get the memory it once had if some other program 'took' the memory that was given back to the OS. FreeBSD's current scheme is to kill a program that asks for more memory in an out-of-memory/VM situation, but I don't think those kinds of problems are within the scope of ANSI-C.