From owner-freebsd-hackers Fri Jul 16 7: 3: 7 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from kronos.alcnet.com (kronos.alcnet.com [63.69.28.22]) by hub.freebsd.org (Postfix) with ESMTP id BA0B5150AB for ; Fri, 16 Jul 1999 07:03:03 -0700 (PDT) (envelope-from kbyanc@alcnet.com) X-Provider: ALC Communications, Inc. http://www.alcnet.com/ Received: from kbyanc (ws-41.alcnet.com [63.69.28.41]) by kronos.alcnet.com (8.9.3/8.9.3/antispam) with SMTP id KAA73518 for ; Fri, 16 Jul 1999 10:17:57 -0400 (EDT) From: "Kelly Yancey" To: Subject: RE: freebsd-hackers-digest V4 #549 Date: Fri, 16 Jul 1999 10:13:48 -0400 Message-ID: <000801becf95$6c007a80$291c453f@kbyanc.alcnet.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 In-Reply-To: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > Date: Fri, 16 Jul 1999 10:08:08 +1000 > From: "Andrew Reilly" > Subject: Re: Swap overcommit > > On Thu, Jul 15, 1999 at 11:48:41PM +0900, Daniel C. Sobral wrote: > > Actually, applications are written assuming that malloc() will not > > fail, generally speaking. > > Is this really the case? I'm pretty sure I've _never_ ignored the > possibility of a NULL return from malloc, and I've been using it > for nearly 20 years. I usually print a message and exit, but I > never ignore it. I thought that was pretty standard practise. > > This is just a random comment, orthogonal to the overcommit issue, > but I've seen both you and Matthew say this now, and I was surprised > both times. > > - -- > Andrew > I have to concur, I have only been programming in C for about 8 years (although programming in other languages for about 15), and I am always sure to check for the failure of dynamic memory allocation. Almost all malloc calls I've written look something like (taken from actually source code): if((current = malloc(sizeof(struct clientinfo))) == NULL) die("Out of memory"); where die is simply a function which calls fprintf to write the message out to stderr and then exit's the program with an error level of 1. Some programs I've gotten fancier and added a second parameter to die() to specify the error level to return. In any event, I like to hope that everyone checks for malloc returning null (since FreeBSD still returns NULL when the resource limit is hit). I always have just assumed everyone did (actually, before this thread, I just assumed returning NULL was more common than it is). I'm all for overcommit, before this thread I never thought one way or the other about it, but I feel that the case for overcommit has been made. And, as is always the case, the offer has been extended for the proponents of non-overcommit to put their source where their mouth is....needless to say no one has stepped up. The argument over overcommit vs. non-overcommit then is irrelevant until someone from the non-overcommit produces patches so the world can see for themselves what they are talking about. I would like to see the discussion die. On the other hand, I find the discussion about the merits of overcommit and the (albeit not always in-depth) explanations of the FreeBSD VM system educational. It would be nice if would could just extract the small amount of signal from this discussion and put it into documentation somewhere. Also, it has got me thinking: does FreeBSD overcommit memory allocated by calloc()? Seems that it would be difficult since the page would have had to have been touched in order be zeroed, but I was curious. Thanks, Kelly ~kbyanc@posi.net~ FreeBSD - The Power To Serve - http://www.freebsd.org/ Join Team FreeBSD - http://www.posi.net/freebsd/Team-FreeBSD To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message