资源上的PHP垃圾收集器?

采取这个简单的循环

while(1) {
    $data = file_get_contents('randomfiles.img');
    $resource = imagecreatefromstring($data);

    //> do some image operation and other stuff
    //> continue

    //> not calling imagedestroy($resource);

}

正如你所看到我没有调用imagedestroy,但我使用相同的变量($resource)来存储imagecreatefromstring()的输入; (类型资源)

当一个新循环启动时,php GC自动释放以前的$资源?

我们只考虑PHP 5.3

谢谢

http://de2.php.net/manual/en/language.types.resource.php

Freeing resources

Thanks to the reference-counting system introduced with PHP 4’s Zend Engine, a resource with no more references to it is detected automatically, and it is freed by the garbage collector. For this reason, it is rarely necessary to free the memory manually.

Note: Persistent database links are an exception to this rule. They are not destroyed by the garbage collector. See the persistent connections section for more information.

相关文章
相关标签/搜索