Date: Sun, 21 Sep 1997 17:05:46 -0600 (MDT) From: Nate Williams <nate@mt.sri.com> To: Eivind Eklund <eivind@bitbox.follo.net> Cc: Nate Williams <nate@mt.sri.com>, Eivind Eklund <perhaps@yes.no>, phk@critter.freebsd.dk, hackers@freebsd.org Subject: Re: Bug in malloc/free (was: Memory leak in getservbyXXX?) Message-ID: <199709212305.RAA28148@rocky.mt.sri.com> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
> > > > >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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709212305.RAA28148>