开发者

PHP Possible Memory Leak

开发者 https://www.devze.com 2023-01-04 07:07 出处:网络
I have a script that loops through a database for images to convert with gd & imagick. I unset or replace all variables and objects in between each loop.

I have a script that loops through a database for images to convert with gd & imagick.

I unset or replace all variables and objects in between each loop.

For each loop, get_memory_usage(1) reveals a concurrent amount of memory used by that script. Which is expected.

But, when I run "top", the %MEM column reports that this script, (same PID), increments with several percentages for each loop.

I destroy all i开发者_C百科mages when I'm done with them, and when I run get_defined_vars(); only the standard globals and a few variables I have is set.

Why is "top" % Memory Usage different than what PHP reports?

After 10 loops, PHP has taken 20% percetage of the system memory.

I run php 5.2.6 on Debian 5


Are you passing the first parameter to memory_get_usage()? If not, you should try that first. For any further information, we would need your source code.


I'll have to answer this one my self.

Upgrading to PHP 5.3.2 eliminated the problem with garabage stacking up at such big ratios.

Because there is some leaks I can't identify, and reset in terms of GD image resources filling up no matter what I do, I've decided to have a perl script run the while loops, and executing the PHP script

system("php /opt/cron/tasks.php");

This way PHP always empty the buffer/memory.

0

精彩评论

暂无评论...
验证码 换一张
取 消