调试 PHP 内存泄漏。跟踪引用计数?
我有一个相当大的 PHP 脚本,该脚本正在泄漏内存。我已经能够找出哪个对象正在泄漏,但我无法找出脚本中的何处泄漏。我的脚本的某些部分保留对泄漏对象的引用。
有什么方法可以跟踪(最好是回溯)PHP 对象的引用计数在何处/何时增加或减少?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用分析工具来找出内存泄漏的原因,我更喜欢 http://xdebug.org/ 和 http://code.google.com/p/webgrind
http://derickrethans.nl/xdebug-and-tracing-memory-usage.html
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.