From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 2 21:14:22 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 28F30106566B for ; Thu, 2 Dec 2010 21:14:22 +0000 (UTC) (envelope-from artemb@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id D3CD68FC17 for ; Thu, 2 Dec 2010 21:14:21 +0000 (UTC) Received: by qyk36 with SMTP id 36so5701394qyk.13 for ; Thu, 02 Dec 2010 13:14:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=2MHUh1ROiY8hxTqDDZIuUcLZ+DsfzO8PpS5LECrWQyA=; b=UeFwTAkRlNLIMWWcnYplu4KF4d1/MqwoXygleccniqfYZYPblHog++WI6dtBTVtv1s Fp4DbMbWDD+wTCxqzhTkHBnPq6cOqXT/H8sfmXgXh3F7UwvXRJIj6CfZB7pq+Q/sNRq6 905JdxzkaRUvwI2PGbrN6qDErdFiNhdXvh3bU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=XrqlJIs++57hjJs4HTrZ3uYfQqJRNQeOFRIWSEb9Ro2bK0vlsDv+qb/42Zq+fyqd+0 qnRZlhWKLgs3nW81hG3pf8IfTTubEio372OXerrX3nOWrg8CqLIMCFxehkR5zEZjgZAQ qssAe9Bo4TSXwMBOYoGKBRJjtk5j256mgE92Y= MIME-Version: 1.0 Received: by 10.229.88.146 with SMTP id a18mr484252qcm.60.1291324460481; Thu, 02 Dec 2010 13:14:20 -0800 (PST) Sender: artemb@gmail.com Received: by 10.220.177.195 with HTTP; Thu, 2 Dec 2010 13:14:20 -0800 (PST) In-Reply-To: References: Date: Thu, 2 Dec 2010 13:14:20 -0800 X-Google-Sender-Auth: Js9bUm9HFz95iwp10LUUvNUmtr8 Message-ID: From: Artem Belevich 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:14:22 -0000 Hi, 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? Perhaps that malloc has two ways of grabbing memory from system -- sbrk() and mmap() and they are subject to different limits. I believe these days malloc is allowed to use both but prefers mmap which would explain why RLIMIT_DATA didn't have much effect. Try forcing malloc to use sbrk only via MALLOC_OPTIONS=3DDm (not sure if that's correct way to specify my intent, though). --Artem