<?php
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
--
BOFH Excuse #131:
telnet: Unable to connect to remote host: Connection refused
On Tue, 29 Jul 2003 13:52:39 +0200
Magnus Maatta magnus@php.net wrote:
<?php
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 timePHP4:
[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