From owner-freebsd-stable@FreeBSD.ORG Sat Feb 23 12:14:22 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DAE116A406 for ; Sat, 23 Feb 2008 12:14:22 +0000 (UTC) (envelope-from arun.balakrishnan@wipro.com) Received: from wipro-blr-out01.wipro.com (wipro-blr-out01.wipro.com [203.91.198.74]) by mx1.freebsd.org (Postfix) with ESMTP id 83B2E13C448 for ; Sat, 23 Feb 2008 12:14:21 +0000 (UTC) (envelope-from arun.balakrishnan@wipro.com) X-AuditID: cb5bdd57-adf37bb000000741-d8-47c0171d213b Received: from blr-ec-bh02.wipro.com (unknown [10.201.50.92]) by wipro-blr-out01.wipro.com (Symantec Mail Security) with ESMTP id 5F2824E4004 for ; Sat, 23 Feb 2008 18:22:45 +0530 (IST) Received: from BLR-SJP-MBX01.wipro.com ([10.101.50.182]) by blr-ec-bh02.wipro.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 23 Feb 2008 17:28:10 +0530 Received: from [127.0.0.1] ([10.115.5.159]) by BLR-SJP-MBX01.wipro.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 23 Feb 2008 17:27:20 +0530 Message-ID: <47C00A1B.5030708@wipro.com> Date: Sat, 23 Feb 2008 17:27:15 +0530 From: "Arun Balakrishnan (WT01 - Computing, Storage & Software Products)" User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) To: freebsd-stable@freebsd.org content-transfer-encoding: 7bit X-OriginalArrivalTime: 23 Feb 2008 11:57:20.0368 (UTC) FILETIME=[3E6A7700:01C87613] X-Brightmail-Tracker: AAAAAA== MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Memory Leak under FreeBSD 6.0 RELEASE X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Feb 2008 12:14:22 -0000 Hi, We are currently working on a project wherein we are porting a library from GNU/Linux to FreeBSD 6.0 - RELEASE 32-bit and 64-bit. As part of the standard memory leak tests, we noticed that the ported library is leaking memory. After lots of analysis we found something very strange. Just repeatedly loading and unloading our library was itself throwing up a leak. We are able to reproduce a similar leak using the following steps: 1. SimpleLib.cpp - Simple dummy library 2. LibLoader.cpp - Utility to repeatedly load the library 3. Compile as mentioned 4. Run under Valgrind for multiple times (31 times in our example. Hard coded for simpilicity) =================SimpleLib.cpp=================== #include #include class CLeaker { public: CLeaker() { }; virtual ~CLeaker() { }; }; CLeaker obj; ================LibLoader.cpp====================== #include "stdio.h" #include "dlfcn.h" #include #include #include int main() { int i = 0; int loop = 31; while (i