From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 2 21:11:48 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDE491065694 for ; Thu, 2 Dec 2010 21:11:48 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-gy0-f182.google.com (mail-gy0-f182.google.com [209.85.160.182]) by mx1.freebsd.org (Postfix) with ESMTP id A90C68FC13 for ; Thu, 2 Dec 2010 21:11:48 +0000 (UTC) Received: by gyf3 with SMTP id 3so4641565gyf.13 for ; Thu, 02 Dec 2010 13:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=AjYh7m4INeb0WoPZDZW2c5nEXcNTTk2t7wGAXBQZlBI=; b=LBh7Mo8CE5THdUDSmBGEWbah66zePwsjLbtDpifaa+49Ur+rEv0oF84G8geH6XzsWI QtXmjwl4Bnk4RTADxoGiJe9FQWjGFdtqOtG0J0RvC6bD5k4I1zHn3VjgIhQVyHDBS3QR JpzbXjVu/JrkCHAA54a6zwNVJuGUHst5EDR1w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=XPFHL3jMlMJdnAoyylwNOjYnaWvGZzbi8EgZbqKgSkVNK4maSbUZ+K+I2jEJRnush+ sXMYnoqvADyiP5UgXELwGHaNE3+Y8LkNpW93j6H+R8Cz6sNSXmQhHMOrUqYwgWRKC/lH vnc+wLetA0U36cbNff27jC/23Zb94uBs4DxBM= MIME-Version: 1.0 Received: by 10.231.31.6 with SMTP id w6mr746429ibc.147.1291324307791; Thu, 02 Dec 2010 13:11:47 -0800 (PST) Received: by 10.231.21.35 with HTTP; Thu, 2 Dec 2010 13:11:47 -0800 (PST) In-Reply-To: References: Date: Thu, 2 Dec 2010 13:11:47 -0800 Message-ID: From: Matthew Fleming To: Andrew Duane Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "freebsd-hackers@freebsd.org" Subject: Re: Question about process rlimits X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Dec 2010 21:11:49 -0000 On Thu, Dec 2, 2010 at 12:51 PM, Andrew Duane wrote: > > I've been poking at some bugs we have around pushing user memory to/past = the limits of our box, and decided to try seeing what happens on a stock Fr= eeBSD system (7.1 in this case). > > Basically I have a program that mallocs big memory chunks and zeros them = to consume both physical and virtual memory. I had expected the program to = stop malloc'ing when brk() reaches the process' RLIMIT_DATA (512MB cur and = max). It didn't. It happily malloc'd many gigabytes of memory until I stopp= ed it. > > On our 6.2 based product boxes, RLIMIT_DATA correctly stops the malloc fr= om continuing, just like the manuals say. > > Am I missing something? Starting on FreeBSD 7, the default malloc(3) implementation uses mmap(2), not brk(2) to manage its address space. There are two ways to deal with this: 1) edit /etc/malloc.conf and add the 'D' option to force malloc to use sbrk(2). I haven't tried this one. 2) limit the total virtual memory allowed by a process, RLIMIT_VMEM. This is what we used when migrating from FreeBSD 6 to 7. Cheers, matthew