I’m trying to track down a memory leak in a PHP Program (Magento, if it matters). The basic problem seems to be a leak in some object/class that’s growing over time. That is, the more information that gets logged to the database, the more memory certain application processes end up using. Magento’s a highly abstract system, so it’s not always clear what code is being run that’s consuming so much memory. That’s what I’m trying to track down.
I’ve been using memory_get_peak_usage at the end of the program bootstrap file to benchmark performance, and seen a steady growth from 250MB of peak use, to 310MB of peak use in about a week. I would like to use memory_get_peak_usage intermittently throughout the execution cycle to ask
What was the peak usage prior to this call? [later in the cycle] What was the peak usage prior to this new call?
The problem I’m running into is, once I call memory_get_peak_usage once, any future call returns the same value as the first call, even when I know the peak usage has changed. This leads me to believe that after memory_get_peak_usage is called once, PHP caches the result. I would like to uncache it to perform the testing outlined above.
-
Can I call
memory_get_peak_usagemultiple times? -
Are there alternative to profiling the scenario I’ve described above. Some feature of xDebug maybe?
Not sure on that one.
Have a look at the XDebug profile page. It’s been awhile since I have profiled an app, but when I did I followed the write-up and worked great.