From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 30 07:42:18 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 6A6121065674 for ; Wed, 30 Jun 2010 07:42:18 +0000 (UTC) (envelope-from dhruvakm@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 2808B8FC19 for ; Wed, 30 Jun 2010 07:42:17 +0000 (UTC) Received: by qyk32 with SMTP id 32so88618qyk.13 for ; Wed, 30 Jun 2010 00:42:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=44kzpV5IMIH8UltYNaK7disrwdbRMlJGi/Xj5JJaNxU=; b=Lp0efTfyfVkpt5nBvK7KurwtYH69M46vLsxXkJymo4Tphd/Aj+Pe3xz5aBP1VgRL1F G5nmhiv8y7N72znzd6w4nSQkcwlET1N+lj1ybmgolm1eKQzXL9KNfEoNO0jAp3VPXU4g 0sIh3sfNGV+TxH8v85IuT3BMVeW7bw4hVq4ZY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=CBYqd0jATBHlV5ATrhSLL6kUXSGvGLTzIBu7xqDX8O2nYhR8saKe9uyshZVU1FrCUl Am1W4uFIz1nxbHeVRsLgMeLs4bu2FsC4fjbGg+6Z6/xffMYCHX+k1Ka6lvB30n7Kxm0o q/IVstioMxcVYqUOffYpIUohsdUHOgFfv/5TU= MIME-Version: 1.0 Received: by 10.224.79.226 with SMTP id q34mr5830205qak.83.1277882355803; Wed, 30 Jun 2010 00:19:15 -0700 (PDT) Received: by 10.229.184.75 with HTTP; Wed, 30 Jun 2010 00:19:11 -0700 (PDT) Date: Wed, 30 Jun 2010 12:49:12 +0530 Message-ID: From: dhruva To: FreeBSD Hackers Content-Type: text/plain; charset=ISO-8859-1 Subject: mallinfo equivalent on FreeBSD 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: Wed, 30 Jun 2010 07:42:18 -0000 Hello, I would like to know the memory usage (total virtual memory) inside a process and make decisions accordingly. To be more specific, I am using BerkeleyDB backed set or std::set (C++ STL) depending on my current memory usage as my process will need to run in a resource constrained environment. By the way, this is user mode application. Some things I am considering/tried: 1. GNU/Linux has mallinfo and I had my code working based on the information I get from the call. 2. I tried using getrusage() and it does not give the total virtual memory usage. 3. Another approach is to set the memory soft limit to the watermark I am interested, trap SIGSEGV and increase the watermark to the original value (save it before modifying). The problem here would be to differentiate between different causes for SIGSEGV and handling them differently. In M$ (Windoze), I could have done this using structured exception handling around the call to malloc. The problem in #3 would be to revert once the memory usage has gone below the watermark. Any suggestions would help me progress. with best regards, dhruva