Re: Memory leak occurs when exec() function is used on Windows platform

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



melmack wrote:
Hi

I have a big problem with shell commands execution via PHP.
I have written a very short PHP script ilustrating the problem:


<?php


for($i=0;$i<1000;$i++)
{ exec("test.bat");


}

?> test.bat is just an empty file.

This script causes about 10 MB memory leak. It can be observed by usage of performance system monitor. This problems occurs in all available enviroments: - IIS Webserver. - Apache webserver - PHP command line interpreter

Memory leak is observable only on Windows platform (tested on Windows XP). On Linux everything works OK.

Does someone know how to solve this problem? Any help appreciated

Best regards Melmack

I've found exec to be flaky enough on windows that instead I use com to spawn the new process.

$shell = new COM('WScript.Shell');
$return = $shell->Run($cmd, 0, false);
unset ($shell);

Faster and no leaks ;) Only downside is you have to wrap cross-platform code with windows detection.

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux