According to my xdebug output, is_array() leaks the amount of memory that gets passed to it as an argument. If I pass it a large array, it leaks a ton of memory just in order to check if it's an array.
Is there a workaround for this?
17.4313 21858520 +70004 -> is_array() [...]/app/app_model.php:526
Here's the code snippet that causes the leak:
$ret = $this->behaviors[$b[$i]]->afterFind($this, $results, true);
if (is_array($ret)) {
$results = $ret;
}
I'm running this on Linux (Ubuntu 9.04)
PHP: 5.3.2
xdebug: 2.0.5
uname -a gives me this:
Linux linux8 2.6.28-19-server #64-Ubuntu SMP Wed Aug 18 21:57:33 UTC 2010 i686 GNU/Linux
My first reaction:
Select isn't broken.
My second reaction:
You can conclude three things:
is_array
) is broken - You are the first one to noticeA widely spread and used function is most often not the problem. Try to narrow down the occurence of the 'xdebug leak report' by running simpler code:
$arr = array_fill( 0, 10000, "content" );
$mallocbytes=true;// set to true to get process
$usage=memory_get_usage(!$mallocbytes);
for( $i=0; $i!=1000000; $i=$i+1) {
is_array($arr);
$newusage=memory_get_usage(!$mallocbytes);
if( $newusage != $usage ) {
print( "diff after $i'th is_array: ".($newusage-$usage)."\n" );
}
$usage=$newusage;
}
Take a look at the actual memory consumption of your PHP runtime. I bet it won't grow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With