Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3638 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2009 invoked from network); 29 Jul 2003 16:59:23 -0000 Received: from unknown (HELO vckyb1.nw.wakwak.com) (211.9.230.144) by pb1.pair.com with SMTP; 29 Jul 2003 16:59:23 -0000 Received: from at.wakwak.com (at.wakwak.com [211.9.230.135:25]) by vckyb1.nw.wakwak.com (Postfix) with ESMTP id E2AB93FE46; Wed, 30 Jul 2003 01:59:21 +0900 (JST) Received: from enigma (newcycle.as.wakwak.ne.jp [218.225.209.145]) by at.wakwak.com (8.12.9/8.12.9/2003-06-03) with SMTP id h6TGxLdO014483; Wed, 30 Jul 2003 01:59:21 +0900 (JST) (envelope-from moriyoshi@at.wakwak.com) Date: Wed, 30 Jul 2003 02:03:49 +0900 To: Magnus Maatta Cc: internals@lists.php.net Message-ID: <20030730020349.0b036b9b.moriyoshi@at.wakwak.com> In-Reply-To: <20030729135239.1251bcab.magnus@php.net> References: <20030729135239.1251bcab.magnus@php.net> X-Mailer: Sylpheed version 0.8.2 (GTK+ 1.2.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Memory leaks in PHP_4_3 and HEAD From: moriyoshi@at.wakwak.com (Moriyoshi Koizumi) On Tue, 29 Jul 2003 13:52:39 +0200 Magnus Maatta wrote: > class a { > var $items = array(); > function a() { > } > > } > class b { > var $a; > function b(&$a) { > $this->a = &$a; > } > } > $a = new a(); > for ($i = 0; $i <= 4; $i++) { > $a->items[] = new b($a); > } > print_r($a); > ?> > > > With PHP5: > [4] => b Object > ( > [a] => a Object > *RECURSION* > ) > > ) > > ) > /opt/dev/php/php5/Zend/zend_hash.c(374) : Freeing 0x4153718C (35 bytes), script=24811.php > Last leak repeated 4 times > /opt/dev/php/php5/Zend/zend_hash.c(233) : Freeing 0x41537130 (37 bytes), script=24811.php > Last leak repeated 5 times > /opt/dev/php/php5/Zend/zend_API.c(677) : Freeing 0x415370DC (32 bytes), script=24811.php > /opt/dev/php/php5/Zend/zend_hash.c(154) : Actual location (location was relayed) > Last leak repeated 5 times > /opt/dev/php/php5/Zend/zend_execute.c(3037) : Freeing 0x41537078 (44 bytes), script=24811.php > /opt/dev/php/php5/Zend/zend_API.c(676) : Actual location (location was relayed) > Last leak repeated 5 times > /opt/dev/php/php5/Zend/zend_objects.c(95) : Freeing 0x41537034 (12 bytes), script=24811.php > Last leak repeated 5 times > /opt/dev/php/php5/Zend/zend_execute.c(3036) : Freeing 0x41536FF0 (16 bytes), script=24811.php > Last leak repeated 5 times > /opt/dev/php/php5/Zend/zend_variables.c(123) : Freeing 0x41538EE8 (32 bytes), script=24811.php > /opt/dev/php/php5/Zend/zend_hash.c(154) : Actual location (location was relayed) > /opt/dev/php/php5/Zend/zend_execute.c(793) : Freeing 0x41538E84 (44 bytes), script=24811.php > /opt/dev/php/php5/Zend/zend_variables.c(122) : Actual location (location was relayed) > Last leak repeated 1 time > > > PHP4: > [4] => b Object > ( > [a] => a Object > ( > [items] => Array > *RECURSION* > ) > > ) > > ) > > ) > /opt/dev/php/php4/Zend/zend_hash.c(406) : Freeing 0x081F009C (35 bytes), script=24811.php > Last leak repeated 4 times > /opt/dev/php/php4/Zend/zend_hash.c(178) : Freeing 0x081EFFF4 (32 bytes), script=24811.php > Last leak repeated 6 times > /opt/dev/php/php4/Zend/zend_API.c(594) : Freeing 0x081EFF94 (44 bytes), script=24811.php > /opt/dev/php/php4/Zend/zend_API.c(582) : Actual location (location was relayed) > Last leak repeated 5 times > /opt/dev/php/php4/Zend/zend_execute.c(1975) : Freeing 0x081EFF54 (12 bytes), script=24811.php > Last leak repeated 5 times > /opt/dev/php/php4/Zend/zend_hash.c(262) : Freeing 0x081EFEA4 (37 bytes), script=24811.php > Last leak repeated 5 times > /opt/dev/php/php4/Zend/zend_execute.c(774) : Freeing 0x081F1454 (44 bytes), script=24811.php > /opt/dev/php/php4/Zend/zend_variables.c(122) : Actual location (location was relayed) > Last leak repeated 1 time That's a known problem. As of the current engine implementation, circular referencing is just inevitable and will end up with lots of leaks. This couldn't be a big deal unless you are trying to make a long-living application with a reference-count-based scripting language. (But it can be prevented with some trick IMO) http://msdn.microsoft.com/library/en-us/vbcon98/html/vbcondealingwithcircularreferences.asp Hope this helps. Moriyoshi