From owner-freebsd-current@FreeBSD.ORG Tue Jun 13 23:05:00 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 607F416A47F for ; Tue, 13 Jun 2006 23:05:00 +0000 (UTC) (envelope-from dunstan@laptop.freebsd.czest.pl) Received: from laptop.freebsd.czest.pl (gw98.internetdsl.tpnet.pl [80.53.74.98]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6AE7343D58 for ; Tue, 13 Jun 2006 23:04:55 +0000 (GMT) (envelope-from dunstan@laptop.freebsd.czest.pl) Received: from laptop.freebsd.czest.pl (localhost [127.0.0.1]) by laptop.freebsd.czest.pl (8.13.6/8.13.4) with ESMTP id k5E15VW5002668 for ; Wed, 14 Jun 2006 01:05:31 GMT (envelope-from dunstan@laptop.freebsd.czest.pl) Received: (from dunstan@localhost) by laptop.freebsd.czest.pl (8.13.6/8.13.4/Submit) id k5E15Vwt002667 for freebsd-current@freebsd.org; Wed, 14 Jun 2006 01:05:31 GMT (envelope-from dunstan) Date: Wed, 14 Jun 2006 01:05:31 +0000 From: "Wojciech A. Koszek" To: freebsd-current@freebsd.org Message-ID: <20060614010531.GA2033@FreeBSD.czest.pl> Mail-Followup-To: freebsd-current@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline User-Agent: Mutt/1.5.11 Subject: (no subject) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2006 23:05:00 -0000 Hello, I have implemented The MemTrace -- a simple tool, which lets you see where kernel memory allocation was done -- source file name, line number, malloc'ed type and size, as well as the address of the allocated memory. Not only does it track memory allocation, but also free() calls with allocated addresses. Each allocation is tracked until free() is done, which means memory chunk was properly deallocated. Such case won't be reported. Results are kept in a fixed-sized cache, which is available through sysctl vm.memtrace.show. Number of allocations is specified with MEMTRACE_ENTRIES variable. If large number of unfree'ed memory is investigated, there's a possibility for fetching useful data via ktr(9) for later analysis. Thus, you'll have to set KTR_MALLOC in debug.ktr.mask. You can also use ALQ with KTR, if you want to obtain a lot of entries. Packed source code is here: http://people.freebsd.org/~wkoszek/mtrace-20060613.tgz You can get this tool from perforce.freebsd.org, exact location: //depot/user/wkoszek/mtrace/... Please let me know if you've found it useful. I wonder if we could have it commited, upon careful testing. Thanks, -- Wojciech A. Koszek wkoszek@FreeBSD.org http://FreeBSD.czest.pl/dunstan/