#29511 [Opn->Bgs]: popen memory leak

From: Date: Tue, 17 Aug 2004 15:58:53 +0000
Subject: #29511 [Opn->Bgs]: popen memory leak
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-64800@lists.php.net to get a copy of this message
ID: 29511 Updated by: tony2001@php.net Reported By: mario at mariomedina dot net -Status: Open +Status: Bogus Bug Type: Reproducible crash Operating System: Linux PHP Version: 5.0.0 New Comment: Can't find any leaks/bugs there. It's quite expected that memory consumption at the end of the script will be greater than at the beginning. All this memory is being freed at the end of the request, so there is no leaks at all. Btw, PHP reports memleaks (if you turned on appropriate option in php.ini), so you'll see them when they really happen. Previous Comments: ------------------------------------------------------------------------ [2004-08-03 22:01:24] mario at mariomedina dot net Description: ------------ When you open a pipe with popen, work with it an then close, some bytes aren't freed, so when you do that task a lot of times you get out of memory error, (with memory limit) and php crash.... It is working with php cgi mode... I tested it on php 4.x, and 5.0.0... When you do proc_open is the same. When you open a popen and it fails then no memory leak exists. Reproduce code: --------------- <? printlog("Iniciando"); for($i=0;$i<10;$i++) { if(($fp=popen("ls","r"))==true) { printlog("Abierto"); while(!feof($fp)) $l=fgets($fp, 8192); printlog("Leido"); fflush($fp); pclose($fp); printlog("Cerrado"); unset($fp); unset($l); printlog("Liberado"); sleep(1); } } printlog("Terminando"); die(); function printlog($src) { printf("%s (%.03fkb): %s\n",date("r"), memory_get_usage()/1024, rtrim($src)); } ?> Expected result: ---------------- I expect that when pipe was closed all the memory is freed. Actual result: -------------- There are memory leak for about 200 bytes ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29511&edit=1

« previous php.bugs (#64800) next »