|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-08-17 17:58 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 22:00:01 2025 UTC |
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