Hi,

I am facing some memory leaks with php 5.1.6 that has been fixed in
5.2.0. So I suppose the fix should be somewhere between those
versions, but I couldn't find exactly which line in the NEWS file is
that.

<?php

class foo
{
   var $a1;
   var $a2;
   var $a3;
   var $a4;
   var $a5;
   var $a6;
   var $a7;
   var $a8;
   var $a9;
}

class bar
{
   var $a1;
   var $a2;
   var $a3;
   var $a4;
   var $a5;
   var $a6;
   var $a7;
   var $a8;
}

echo "--- 9 ---\n";
for ($i = 0; $i < 5; $i++){
   $u =& new foo();
   unset($u);
   echo memory_get_usage()."\n";
}

echo "--- 8 ---\n";
for ($i = 0; $i < 5; $i++){
   $u =& new bar();
   unset($u);
   echo memory_get_usage()."\n";
}

?>

Output for 5.1.6:
--- 9 ---
44712
44784
44848
44912
44976
--- 8 ---
45008
45008
45008
45008
45008

Conclusion: memory consumption keeps constant for the class with 8
properties. unset() doesnt frees all the memory up for the class with
9 properties.

Output for 5.2.0:
--- 9 ---
66784
66828
66828
66828
66828
--- 8 ---
66896
66896
66896
66896
66896

Conclusion: memory consumption constant along the whole code, as expected.

I have seen that reported many times in the bugs system, but in all
the cases it ended up being something related to circular references
which is not the case here. Some people also reported that replacing
"unset($obj)" with "$obj = null" would help but I tried it and the
problem remains.

Any help on how to workaround that in userland would be very
appreciated. Surely upgrading will fix that, but I am trying to keep
compatibility with prior versions as much as possible.

Best,
~IF.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to