I'm struggling here, probably due to the fact that I'm not a php expert (yet) and definitely a little lacking in linux administration, but learning. I've looked for documentation on how to find the memory leak that my code definitely has, and a lot of articles suggested xdebug. I got it installed, turned on logging briefly and used tracefile-analyser.php to dump out the following report. The problem I now have, is finding proper documentation on the tracefile script to explain what each column means. Can someone either point me to a straight forward "if you see X, this means it is a memory leak" type documentation or explain how I would find the function calls leaking memory in the following output?
Asked
Active
Viewed 9,191 times
2
-
This is odd. Normally one would not be concerned with a "memory leak" in a php script, since such scripts only have a very limited life time. Another thing is a potential memory leak in the php engine itself! But that is something you cannot trace down with a tool like `xdebug`, you will have to use a classical tool like `ddd` and examine a local build of the php engine. – arkascha Mar 28 '16 at 16:31
-
You need to add some code that can be used to see your problem. Have a look at the answer here for ideas... http://stackoverflow.com/questions/849549/diagnosing-memory-leaks-allowed-memory-size-of-bytes-exhausted – Harry Mar 28 '16 at 19:33
-
It's frustrating; even that article suggests xdebug, but I can't for the life of me figure out the difference between the columns in my report and where the problem is. Does anyone know the difference between the two memory columns? – Chris Hully Mar 28 '16 at 22:05
1 Answers
3
Based on the documentation, if xdebug is set to capture trace information in machine-readable format, it records the amount of memory in use when the program begins a function, and then how much memory is being used when the program exits the function.
I'm not sure what program you are using the parse the trace file, but I would guess that they are displaying the total memory usage for your program in the first column, and in the second column displaying how much memory the individual function uses.
If you are already pulling the traces in machine-readable format (xdebug.trace_format = 1 in your php.ini) you may want to try Xdebug Trace Tree to view the results. It shows a column specifically for the change in memory usage.