From owner-freebsd-hackers Sun Sep 21 23:27:51 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id XAA18264 for hackers-outgoing; Sun, 21 Sep 1997 23:27:51 -0700 (PDT) Received: from usr07.primenet.com (tlambert@usr07.primenet.com [206.165.6.207]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id XAA18255 for ; Sun, 21 Sep 1997 23:27:48 -0700 (PDT) Received: (from tlambert@localhost) by usr07.primenet.com (8.8.5/8.8.5) id XAA16498; Sun, 21 Sep 1997 23:27:34 -0700 (MST) From: Terry Lambert Message-Id: <199709220627.XAA16498@usr07.primenet.com> Subject: Re: Bug in malloc/free (was: Memory leak in getservbyXXX?) To: karpen@ocean.campus.luth.se (Mikael Karpberg) Date: Mon, 22 Sep 1997 06:27:34 +0000 (GMT) Cc: sef@Kithrup.COM, hackers@FreeBSD.ORG In-Reply-To: <199709220412.GAA08834@ocean.campus.luth.se> from "Mikael Karpberg" at Sep 22, 97 06:12:36 am X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > However, if I understand everything right, phkmalloc doesn't shrink the > program's space, but simply tells the OS that the page's contents are not > important and can be disregarded. The program still has enough space > allocated on the swap to write the page to, but there is no need to write > it to that space, and read it back when the memory is accessed. Instead > the page is not reclaimed until the OS needs a free page, and if the program > wants to use the page later, it gets a zeroed page from the system. This > can be guaranteed since there is space on the swap for this page, so another > program can have an idle page be swapped out to there, and the program can > then get that page, after it has been zeroed. > > Then it would indeed be guaranteed that the second malloc() would succeed. > > Am I right? Maybe I'm completely off instead? :-) You're wrong. Memory is overcommited. This means that there is no guarantee that a backing page exists for the kernel to be able to associate it with the process as a result of the fault. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.