I'm building an application with the Yii framework and am trying to determine the cause of an out of memory error. Is it possible to get a stack trace? I've tried doing something like...
function handleShutdown() {
debug_print_backtrace();
$error = error_get_last();
$info = "[SHUTDOWN] file:".$error['file']." | ln:".$error['line']." | msg:".$error['message'] .PHP_EOL;
echo $info;
}
register_shutdown_function('handleShutdown');
But the debug_print_backtrace() doesn't show anything but
#0 handleShutdown()
[SHUTDOWN] file:C:\Users\bkuhl\htdocs\instaLabel\yii-1.1.12\base\CModule.php | ln:530 | msg:Allowed memory size of 67108864 bytes exhausted (tried to allocate 65488 bytes)
I've checked CModule.php and there's no line number 530 in that file. It only goes to 518.
In my case, this was happening because I had infinite function recursion. When I added the xDebug extension to PHP it threw an accurate error due to the function call limit.
Profile your app with xdebug. It should tell you which function is called how often and how much memory it eats.
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