gettype()泄漏内存

kap*_*els 0 php twitter xdebug twitter-oauth

我正在使用twitter-async库Twitter进行一些oauth调用,但最终,大量内存正在被耗尽.我尝试运行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
Run Code Online (Sandbox Code Playgroud)

fir*_*ire 5

文档:

永远不要使用gettype()来测试某种类型,因为返回的字符串可能会在将来的版本中发生变化.另外,它也很慢,因为它涉及字符串比较.

而是使用is_*函数.

如使用is_array,is_string等等.