From owner-freebsd-ports@FreeBSD.ORG Thu Apr 7 17:59:20 2005 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E458516A4CE; Thu, 7 Apr 2005 17:59:20 +0000 (GMT) Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id B5C7543D45; Thu, 7 Apr 2005 17:59:20 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from mac.com (smtpin01-en2 [10.13.10.146]) id j37HxJIc005095; Thu, 7 Apr 2005 10:59:19 -0700 (PDT) Received: from [10.1.1.245] (nfw2.codefab.com [199.103.21.225] (may be forged)) (authenticated bits=0)j37HxIJJ000105; Thu, 7 Apr 2005 10:59:18 -0700 (PDT) In-Reply-To: <27B2E82614CBB44BB1E8767F89247B710B7013@srv-sbs2003.BEENOX.COM> References: <27B2E82614CBB44BB1E8767F89247B710B7013@srv-sbs2003.BEENOX.COM> Mime-Version: 1.0 (Apple Message framework v619.2) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Charles Swiger Date: Thu, 7 Apr 2005 13:59:17 -0400 To: Sebastien Poirier X-Mailer: Apple Mail (2.619.2) cc: ports@FreeBSD.org cc: barner@FreeBSD.org Subject: Re: FreeBSD Port: valgrind-snapshot-352_3 X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Apr 2005 17:59:21 -0000 On Apr 6, 2005, at 1:20 PM, Sebastien Poirier wrote: > I would like to know if your port is aimed for Mac OS X too. > We are looking for a memory debug tools for Mac OS X and Valgrind > seems to be the best for this purpose. Hi, Sebastian-- The "leaks" command which comes with OS X is pretty darn useful: % cat /tmp/foo.c #include void bad(int size) { int x; char *leaky; leaky = malloc(size); for (x = 0; x < size; x++) leaky[x] = (char) x + 'a'; leaky = NULL; } main() { bad(10); bad(20); sleep(100); } % MallocStackLogging=1 /tmp/foo & malloc[16451]: recording stacks using standard recorder % leaks foo Process 16451: 10 nodes malloced for 1 KB Process 16451: 2 leaks for 48 total leaked bytes. Leak: 0x00100150 size=32 string 'abcdefghijklmnopqrst' Call stack: [thread 1a27]: | 0x0 | start | _start | main | bad | malloc | malloc_zone_malloc Leak: 0x00100140 size=16 string 'abcdefghij' Call stack: [thread 1a27]: | 0x0 | start | _start | main | bad | malloc | malloc_zone_malloc Even if you don't run with that ENV variable set, simply seeing the size and the contents of leaked memory is often enough to help ("do you know how big your structures are?" :-), but having the call stack responsible for the allocation of the memory is a godsend. -- -Chuck