Re: how to detect circular reference caused mem leaks on win32
| From: | Stanislav Malyshev | Date: | Fri, 18 Aug 2000 21:09:31 +0000 |
| Subject: | Re: how to detect circular reference caused mem leaks on win32 | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-29539@lists.php.net to get a copy of this message | ||
AL>> 1) If I╢m sticking a loop around it, will it leak more than 140 bytes
First: unless you do unset($o) immediately after that, it doesn't matter
if it "leaks" or not, since $o is not freed anyway until the end of teh
script.
Second: it would leak in a lop only if you use different variables or set
and unset $o. The latter is not really common - why would you construct so
complicate dobject just to unset it immediately?
AL>> 2) what╢s the actual reason for that leak, why is it needed?
Actual reason is that zval for $o->x cannot be freed when $o is freed,
because it has reference count too high.
AL>> 3) It only leaks one time (on creation) not an access or sth. different?
This leak is not like leak in your water supply tubes :) There's no
"place" of the leak, it just doesn't free that memory. It never frees it,
so it is impossible to say "where it doesn't free it". It doesn't free it
in any place you want :) This memory is allocated once, if this is what
you meant.
AL>> 4) Do "normal" propertes like $o->x->b=5; increase the leak or is it two
AL>> different things...
Well, all zvals (with all properties) in the circle are not freed, meaning
more properties you have for the zval, more you lose. However, loss is not
so huge (some 80-100 bytes per zval), so unless you have millions of them
you shouldn't really worry.
--
Stanislav Malyshev stas@zend.com
+972-3-6139665 ext.106