Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28473 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1673 invoked by uid 1010); 19 Mar 2007 23:21:55 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 1658 invoked from network); 19 Mar 2007 23:21:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2007 23:21:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.114 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.114 unknown Windows 2000 SP4, XP SP1 Received: from [63.205.162.114] ([63.205.162.114:43675] helo=us-ex1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/EC-01604-11B1FF54 for ; Mon, 19 Mar 2007 18:21:55 -0500 Received: from [127.0.0.1] ([192.168.16.109]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 19 Mar 2007 16:21:51 -0700 Message-ID: <45FF1B0C.2060205@zend.com> Date: Mon, 19 Mar 2007 16:21:48 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0b2 (Windows/20070116) MIME-Version: 1.0 To: Oliver Block CC: internals@lists.php.net References: <200703192315.l2JNFWbv003731@post.webmailer.de> In-Reply-To: <200703192315.l2JNFWbv003731@post.webmailer.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Mar 2007 23:21:51.0481 (UTC) FILETIME=[5FD83690:01C76A7D] Subject: Re: [PHP-DEV] could need some help with memory leaks From: stas@zend.com (Stanislav Malyshev) Oliver Block wrote: > Hello, > > I rewrote imap_mail_compose() and (almost) everything works fine, but I can't > get rid of some memory leaks. > > In order to compose nested mutlipart messages I created a hash_table > > [Mon Mar 19 23:44:36 2007] Script: '/root/compose_multipart.php' > /usr/local/src/php-5.2.1/Zend/zend_execute.c(1062) : Freeing 0x40835DA4 (32 > bytes), script=/root/compose_multipart.php > /usr/local/src/php-5.2.1/Zend/zend_alloc.c(1917) : Actual location (location > was relayed) > [Mon Mar 19 23:44:36 2007] Script: '/root/compose_multipart.php' > /usr/local/src/php-5.2.1/Zend/zend_execute.c(1006) : Freeing 0x40835DF4 (35 > bytes), script=/root/compose_multipart.php > /usr/local/src/php-5.2.1/Zend/zend_hash.c(388) : Actual location (location was > relayed) > Last leak repeated 1 time > [Mon Mar 19 23:44:36 2007] Script: '/root/compose_multipart.php' > /usr/local/src/php-5.2.1/ext/imap/php_imap.c(3340) : Freeing 0x40836E4C (44 > bytes), script=/root/compose_multipart.php > /usr/local/src/php-5.2.1/Zend/zend_API.c(819) : Actual location (location was > relayed) > Last leak repeated 1 time > === Total 5 memory leaks detected === > > That's what I found out so far: > > When the function that is called in the script (/root/compose_multipart.php) is > accessed, the address 0x40835DA4 has the value 0x40835DF4 at the very > beginning. The address 0x40835DF4 has 0x00000000. > > Can anybody help me to understand the output? Well, the output gives you line of code where the block was allocated, e.g.: > /usr/local/src/php-5.2.1/ext/imap/php_imap.c(3340) : Freeing 0x40836E4C (44 > bytes), script=/root/compose_multipart.php Check your code to see what's in this line - that is probably the allocation which was not freed. Usually forgetting to free hashtable generates a number of leak messages, since hashtable has main structure, buckets, etc. -- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/