gettype() 泄漏内存
我正在使用 twitter-async 库 进行一些 oauth 调用twitter 但最终,大量内存被耗尽。我尝试运行 xdebug 执行跟踪,这就是我感觉内存泄漏的地方。
json_decode()
使用 47077232 字节。好的。这很好。
但是 gettype() 呢?为什么这也应该使用类似的内存量?
如何防止这种情况发生?
脚本循环运行,内存使用量不断上升。我在很多地方使用 gc_collect_cycles()
并且它显示出改进。但这一次,我无法理解为什么会发生这种情况。
724.1772 47077232 +2118720 -> json_decode() /var/www/html/includes/classes/twitter/EpiTwitter.php:230
724.1926 49157104 +2079872 -> gettype() /var/www/html/includes/classes/twitter/EpiTwitter.php:232
724.1927 49157104 +0 -> property_exists() /var/www/html/includes/classes/twitter/EpiTwitter.php:240
724.1927 49153520 -3584 -> EpiTwitterJson->__destruct() /var/www/html/includes/classes/twitter/EpiTwitter.php:0
724.1949 46714808 -2438712 -> in_array() /var/www/html/cron.php:156
I'm using the twitter-async library to do some oauth calls to twitter but ultimately, a lot of memory is being used up. I tried running the xdebug execution trace and this is where I feel the memory is getting leaked.
json_decode()
is using 47077232 bytes. Okay. This is fine.
But gettype()
? Why should this too be using similar amount of memory?
How could this be prevented?
The script runs in a loop and the memory usage keeps going up. I'm using gc_collect_cycles()
at number of places and it is showing improvement. But this one, I can't understand why should this happen.
724.1772 47077232 +2118720 -> json_decode() /var/www/html/includes/classes/twitter/EpiTwitter.php:230
724.1926 49157104 +2079872 -> gettype() /var/www/html/includes/classes/twitter/EpiTwitter.php:232
724.1927 49157104 +0 -> property_exists() /var/www/html/includes/classes/twitter/EpiTwitter.php:240
724.1927 49153520 -3584 -> EpiTwitterJson->__destruct() /var/www/html/includes/classes/twitter/EpiTwitter.php:0
724.1949 46714808 -2438712 -> in_array() /var/www/html/cron.php:156
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自文档:
例如使用
is_array
、is_string
等。From the documentation:
e.g. use
is_array
,is_string
etc.