From owner-freebsd-current Mon Apr 12 8: 8:17 1999 Delivered-To: freebsd-current@freebsd.org Received: from misha.cisco.com (misha.cisco.com [171.69.206.50]) by hub.freebsd.org (Postfix) with ESMTP id 2607B14E7A for ; Mon, 12 Apr 1999 08:08:12 -0700 (PDT) (envelope-from mi@misha.cisco.com) Received: (from mi@localhost) by misha.cisco.com (8.9.2/8.9.1) id LAA70241; Mon, 12 Apr 1999 11:05:21 -0400 (EDT) (envelope-from mi) From: Mikhail Teterin Message-Id: <199904121505.LAA70241@misha.cisco.com> Subject: Re: swap-related problems In-Reply-To: <199904120400.VAA15072@apollo.backplane.com> from Matthew Dillon at "Apr 11, 1999 09:00:24 pm" To: dillon@apollo.backplane.com (Matthew Dillon) Date: Mon, 12 Apr 1999 11:05:21 -0400 (EDT) Cc: current@freebsd.org Reply-To: mi@aldan.algebra.com X-Mailer: ELM [version 2.4ME+ PL52 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Matthew Dillon once wrote: > If you unset the datasize limit and the program does not exceed > the maximum system-supported datasize limit, malloc() should not > return NULL even if the system is out of swap. Can you explain why? Our malloc(3) is a little fuzzy as to the circumstances under which malloc will fail, but on Solaris, it is more explicit: RETURN VALUES If there is no available memory, malloc(), realloc(), memalign(), valloc(), and calloc() return a null pointer. I consider being out-of-swap as having "no available memory". Wouldn't you? Now, for better diagnostics and for a possibility of smarter applications, they also have: ERRORS If malloc(), calloc(), or realloc() returns unsuccessfully, errno will be set to indicate the following: ENOMEM size bytes of memory exceeds the physical limits of your system, and cannot be allo- cated. EAGAIN There is not enough memory available AT THIS POINT IN TIME to allocate size bytes of memory; but the application could try again later. > The correct solution is to set a maximum datasize limit. That is > what it is there for. I generally unlimit the datasize for root > and set it to around 64MB for all other users. Wait, I want to give all the memory available to a program, but I want it to be NOTIFIED when no more memory is left. True, I can set the limit to the actual amount of my swap, but that would be hard to maintain and still does not solve a problem of running together with some other memory consuming application. The existing situation is sort of like killing a program for trying to write to disk in excess of the user's quota, or for being ready to RUN when the load is 1. -mi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message