I have a rather large PHP script that is leaking memory. I have been able to figure out what object is leaking, but I have not been able to find out where in the script it is leaking. Some part of my script is keeping a reference to the leaking object.
Is there some way that I can track (and preferably backtrace) where/when a PHP object has it's reference count increased or decreased?
When analyzing possible memory leaks, you need access to the app's memory heap. Then you can analyze the memory contents. Looking at relationships between objects, you create theories on why memory isn't being freed. A common diagnostics data source is a memory dump on Windows or the equivalent core dump on Linux.
What is a memory leak in PHP? A memory leak in PHP is a condition that causes sections of code to continue using memory even though that memory is no longer needed.
To find a memory leak, you've got to look at the system's RAM usage. This can be accomplished in Windows by using the Resource Monitor. In Windows 11/10/8.1: Press Windows+R to open the Run dialog; enter "resmon" and click OK.
You can use profiling tools to find out what is leaking your memory i prefer http://xdebug.org/ and http://code.google.com/p/webgrind
http://derickrethans.nl/xdebug-and-tracing-memory-usage.html
Try to use:
Also, I suggest to write the code in a easy-to-debug manner and separate the debugging procedures from the code.
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