Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64999 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93244 invoked from network); 16 Jan 2013 21:10:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jan 2013 21:10:09 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain zend.com does not designate 209.85.219.41 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.219.41 mail-oa0-f41.google.com Received: from [209.85.219.41] ([209.85.219.41:49348] helo=mail-oa0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0D/82-14541-E2717F05 for ; Wed, 16 Jan 2013 16:10:08 -0500 Received: by mail-oa0-f41.google.com with SMTP id k14so1910842oag.28 for ; Wed, 16 Jan 2013 13:10:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:references:from:mime-version:in-reply-to:date:message-id :subject:to:cc:content-type:content-transfer-encoding :x-gm-message-state; bh=LNqQW2HRW+Fn4Rbfz28QviY6yI2YwCUtxf2HHxS+mbA=; b=P5bTWsk4pcrgwwS3+PKB3BNIwuS9bXbIGor+QZj5FF45ZPibEVm+tnCXNhs9alRSto rA7ewVBmY3yNEVowRs4+T3hROjTo1KYlaaQZrATqw6UVEUviNWDzXvmv5mV0iQI6JBTZ fq1RdPNoQW5aFbKg6ZZXXcp2YaIQxnC8DNuIZJgXuLZxfq/XtD+D0yFeIdQfMSP+TqbU M2kqbUvKtcPiW/GK7GKIW2G63db1B8ye82TinPOAq1N9A6D+cGkCxEqjqQzF/8Pejxy6 xlP7Xykjle6cBxixJofXDsUnJlokv/g7OmFwD1R4FlMDSNVTHl04Pr6sUtI6cjCd1PhT tSAw== X-Received: by 10.60.169.205 with SMTP id ag13mr2096140oec.40.1358370603604; Wed, 16 Jan 2013 13:10:03 -0800 (PST) References: Mime-Version: 1.0 (1.0) In-Reply-To: Date: Wed, 16 Jan 2013 23:10:02 +0200 Message-ID: <7718721987906143875@unknownmsgid> To: Pascal Mathis Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQmyeXrarFfLhQFQQr3S9lhI3G4/aQzgW4cZ1zkdhOqQ1nFrXOizNaggoYZF43zGPDPfQsHlwQLpy0WpBj67qe2BCcYNtpEWZ+fCP9x7qn6YDj/gLRzIfHUKEp74NNTfZ9Zun63w Subject: Re: [PHP-DEV] Memory leak after calling exit() when Zend MM is turned off? From: zeev@zend.com (Zeev Suraski) On 16 =D7=91=D7=99=D7=A0=D7=95 2013, at 22:00, Pascal Mathis wrote: > Hi internals! > > I am currently developing a Zend extension. Because the Zend MM leak repo= rts are not really useful sometimes, I switched the memory manager off with= the environment variable USE_ZEND_ALLOC=3D0, so that I can use valgrind. > > Right now I have found some kind of memory leak. You can use every script= which has an exit()-call to reproduce this leak. For example: > > > > If you run this PHP script with valgrind, it will report some ugly memory= leak: > > valgrind version: valgrind-3.6.0.SVN-Debian > PHP Version: 5.4.10 (debug) > Configure options: --disable-all --disable-cgi --enable-debug > --- > Command: export USE_ZEND_ALLOC=3D0 && valgrind --leak-check=3Dfull php-5.= 4.10-debug test.php > --- > Report: > =3D=3D5693=3D=3D HEAP SUMMARY: > =3D=3D5693=3D=3D in use at exit: 420 bytes in 4 blocks > =3D=3D5693=3D=3D total heap usage: 8,355 allocs, 8,351 frees, 2,503,705= bytes allocated > =3D=3D5693=3D=3D > =3D=3D5693=3D=3D 420 (240 direct, 180 indirect) bytes in 1 blocks are def= initely lost in loss record 4 of > =3D=3D5693=3D=3D at 0x4C244E8: malloc (vg_replace_malloc.c:236) > =3D=3D5693=3D=3D by 0x5E08C4: _emalloc (zend_alloc.c:2423) > =3D=3D5693=3D=3D by 0x5C11C3: compile_file (zend_language_scanner.l:55= 1) > =3D=3D5693=3D=3D by 0x617311: zend_execute_scripts (zend.c:1301) > =3D=3D5693=3D=3D by 0x58A22F: php_execute_script (main.c:2482) > =3D=3D5693=3D=3D by 0x768967: do_cli (php_cli.c:988) > =3D=3D5693=3D=3D by 0x76987C: main (php_cli.c:1364) > =3D=3D5693=3D=3D > =3D=3D5693=3D=3D LEAK SUMMARY: > =3D=3D5693=3D=3D definitely lost: 240 bytes in 1 blocks > =3D=3D5693=3D=3D indirectly lost: 180 bytes in 3 blocks > =3D=3D5693=3D=3D possibly lost: 0 bytes in 0 blocks > =3D=3D5693=3D=3D still reachable: 0 bytes in 0 blocks > =3D=3D5693=3D=3D suppressed: 0 bytes in 0 blocks > > When the Zend memory manager is turned on, everything is fine. Is this be= havior intended? Yes. The implementation of exit() will not necessarily free all allocated blocks. It therefore intentionally suppresses errors that might come from the memory manager regarding leaks - but if you turn off the memory manager and use valgrind - you'd see them. It's not a problem unless you actually use PHP without the memory manager in production, which of course you should not. Zeev