Memory Leak tool for PHP? Using LAMP
Anyone know a good tool for discovery of memleaks for PHP? I can use either client o开发者_Go百科r server side. Thanks
You shouldn't need to manage memory for most applications. This isn't C. However, with that said, I'm assuming you have a good reason to need a memory leak detector in PHP. This article explains memory usage in a slightly outdated (but still relevant) version of PHP. Scroll down to the "Memory management functions in PHP" section for built-in memory management functions.
Here's an overview of the most popular ones:
- memory_get_usage: Gets the total bytes used by the current PHP script
- memory_get_peak_usage: Gets the maximum bytes used by the current PHP script
- ini_get('memory_limit'): Gets the maximum amount of bytes allowed by the current PHP script
I suggest you XDebug and perhaps adding xhprof.
Not hard to implement, easy to work and very nice way to visualize and find leaks (both in time and memory).
精彩评论