I have CLI script that runs over several thousand iterations between runs and it appears to have a memory leak. I'm using a tweaked version of Zend Framework with Smarty for view templating and each iteration uses several MB worth of code. The first run immediately uses nearly 8MB of memory (which is fine) but every following run adds about 80kb.
My main loop looks like this (very simplified)
$users = UsersModel::getUsers();
foreach($users as $user) {
$obj = new doSomethingAwesome();
$obj->run($user);
$obj = null;
unset($obj);
}
The point is that everything in scope should be unset and the memory freed.
My understanding is that PHP runs through its garbage collection process at it's own desire but it does so at the end of functions/methods/scripts. So something must be leaking memory inside doSomethingAwesome() but as I said it is a huge stack of code.
Ideally, I would love to find some sort of tool that displayed all my variables no matter the scope at some point during execution. Some sort of symbol-table viewer for php.
Does anything like that or any other tools that could help nail down memory leaks in php exist?