[CVS] Memleak when assigning a class being property of another class the class
| From: | Markus Fischer | Date: | Tue, 13 Nov 2001 13:27:57 +0000 |
| Subject: | [CVS] Memleak when assigning a class being property of another class the class | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-70345@lists.php.net to get a copy of this message | ||
Ok, the subject probably doesn't make much sense because of the
lack of my proper english ;)
Anyway, consider this:
<?
class bar {
function bar($parent) {
$this->parent = &$parent;
}
}
class foo {
var $num = 0;
function foo() {
$this->bar = new bar(&$this);
$this->num = 1;
}
function call() {
echo "I'm foo\n";
}
}
$f = new foo;
$f->bar->parent->call();
echo $f->bar->parent->num . "\n";
?>
It works ...
mfischer@debian:~$ php -f src/php/oo.php
I'm foo
1
... but ...
./zend_execute.c(467) : Freeing 0x082F96A4 (12 bytes), script=src/php/oo.php
zend_hash.c(260) : Freeing 0x082F79A4 (42 bytes), script=src/php/oo.php
Last leak repeated 2 times
zend_API.c(593) : Freeing 0x082F77A4 (44 bytes), script=src/php/oo.php
zend_API.c(581) : Actual location (location was relayed)
Last leak repeated 1 time
./zend_execute.c(1948) : Freeing 0x082F9664 (12 bytes), script=src/php/oo.php
Last leak repeated 1 time
zend_hash.c(176) : Freeing 0x082EEFA4 (32 bytes), script=src/php/oo.php
Last leak repeated 1 time
on shutdown.
If I remove the reference operator (thus make a copy of the object [which I
don't want]) at any point there is no leak.
- Markus
ps: na don't tell me this is a known issue :-)