I have a php script that uses Doctrine2 and Zend to calculate some things from a database and send some emails for 30.000 users.
My script is leaking memory and I want to know which are the objects that are consuming that memory, and if it is possible who is keeping a reference to them (thus not allowing them to be released).
Im using php 5.3.x, so plain circular references shouldn’t be the problem.
Ive tried using xdebug trace capabilities to get mem_delta with no success (too much data).
Ive tried manually adding memory_get_usage before and after the important functions. But the only conclusion that I got was that I loose around 400k per user, and 3000 users times that gives me the 1Gb that i have available.
Are there any other ways to know where and why memory is leaking?
Thanks
You could try sending say 10 emails and then inserting this
http://nz.php.net/manual/en/function.get-defined-vars.php
At the end of the script or after the email is sent (depending on how your code is setup).
This should tell you what is still loaded, and what you can unset / turn into a reference.
Also if there are two many things loaded you get this near start and end of your code and work out the difference.