My dedicated server has 32GB RAM and the memory just goes up and up constantly and I have to reboot it daily now. This is costing me customers and money.
I am having a hard time finding where the memory leak is. All I can find online is people say "Use xdebug" but I haven't been able to find any xdebug tutorials on finding memory leaks. I have tried printing memory_get_usage before and after function calls but is that the right way to do it?
I have MANY php scripts running - some from visitors, others from cron jobs - and I need to find which one(s) of them is leaking memory and fix it ASAP but I don't even know how to determine if a given function is leaking memory or not.
I have tried printing memory_get_usage before a function call and after, and it goes up, but then if I call the function more than once, it doesn't go up anymore. Can someone please explain this and tell me how I can simply and easily tell if a PHP function has a memory leak?
auto_append_file
script and thememory_get_*
methods, to log all of your scripts and watch out for the heavy ones.ps
? i.e. a simple cron job to dump output ofps
(with appropriate flags) so you can see which processes are using the most memory each minute. Check your flavour ofps
to sort by memory usage and output full process detail (e.g. process + full command line and environment.)