From owner-freebsd-questions@FreeBSD.ORG Sat Feb 21 15:05:35 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CB3C016A4CE for ; Sat, 21 Feb 2004 15:05:35 -0800 (PST) Received: from out008.verizon.net (out008pub.verizon.net [206.46.170.108]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B8D843D1D for ; Sat, 21 Feb 2004 15:05:35 -0800 (PST) (envelope-from leblanc@keyslapper.org) Received: from keyslapper.org ([151.203.33.188]) by out008.verizon.net (InterMail vM.5.01.06.06 201-253-122-130-106-20030910) with ESMTP id <20040221230534.RPCV10003.out008.verizon.net@keyslapper.org>; Sat, 21 Feb 2004 17:05:34 -0600 Received: from keyslapper.org (localhost [127.0.0.1]) by keyslapper.org (8.12.8p1/8.12.8) with ESMTP id i1LN5bHX039452; Sat, 21 Feb 2004 18:05:38 -0500 (EST) (envelope-from leblanc@keyslapper.org) Received: (from leblanc@localhost) by keyslapper.org (8.12.8p1/8.12.8/Submit) id i1LN5bgc039451; Sat, 21 Feb 2004 18:05:37 -0500 (EST) Date: Sat, 21 Feb 2004 18:05:36 -0500 From: Louis LeBlanc To: David Carter-Hitchin Message-ID: <20040221230536.GA38823@keyslapper.org> Mail-Followup-To: David Carter-Hitchin , freebsd-questions@freebsd.org References: <20040221004102.M268@stoat.clara.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20040221004102.M268@stoat.clara.net> User-Agent: Mutt/1.5.6i X-Authentication-Info: Submitted using SMTP AUTH at out008.verizon.net from [151.203.33.188] at Sat, 21 Feb 2004 17:05:34 -0600 cc: freebsd-questions@freebsd.org Subject: Re: C++ Memory Profiling/Debugging X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: freebsd-questions@freebsd.org List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Feb 2004 23:05:35 -0000 On 02/21/04 12:48 AM, David Carter-Hitchin sat at the `puter and typed: > Hi, > > Does anyone out there know a good C++ memory profiling/debugging tool for > FBSD? I'm looking for a tool like valgrind or purify. I grepped around > in the ports directory and I found "ElectricFence" and "mprof" but these > seem to be for C only (as they refer exclusively to malloc & free). > "bohem-gc" sounds like the kind of package I'm after - but I thought I ask > in case anyone has better ideas... ? devel/dmalloc is pretty good. I'm using it with C on Solaris, but all you do is basically link its library into your process, set a few environment variables, and it will dump a complete list of statistics, based on the values of the environment variables. The most valuable statistic is the origin of every single memory allocation that is not freed. Simply track those made by your code (file name and line number of the malloc are given) and fix them. I found it MUCH easier to integrate and use than Efence or Purify. If your process dynamically allocates memory that isn't intended to be freed, like for internal structure allocation through the life of the process, you might include a routine that frees such pointers in your cleanup process. I have a number of things I have to clear that aren't intended to be freed during the life of the process, so I simply added them within a conditional precompiler block that only gets compiled when I'm building a memory debuggable version. You wouldn't believe the memory leaks I found in (someone else's) production code with this tool. HIGHLY recommended. Good luck. > Please cc me on any replies - I had to drop out of this list sometime ago > as the sheer volume was killing my mailbox... I know what you mean . . . Lou -- Louis LeBlanc leblanc@keyslapper.org Fully Funded Hobbyist, KeySlapper Extrordinaire :) http://www.keyslapper.org ԿԬ Unless hours were cups of sack, and minutes capons, and clocks the tongues of bawds, and dials the signs of leaping houses, and the blessed sun himself a fair, hot wench in flame-colored taffeta, I see no reason why thou shouldst be so superfluous to demand the time of the day. I wasted time and now doth time waste me. -- William Shakespeare