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

From: Date: Mon, 10 Sep 2007 18:17:05 +0000
Subject: Re: Memory leak occurs when exec() function is used on Windows platform
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-28469@lists.php.net to get a copy of this message
Thank you for your reply. Unfortunately your method also causes memory leak. I have tested operating system and I have discovered that batch script listed below causes the same memory leak. That is why I think now that it is however not PHP fault but Windows bug. The Windows batch script contains: for /L %%i in (1,1,500) do cmd /C test.bat where test.bat is just an empty file. Maybe someone knows how to solve this problem? Best regards Melmack Uzytkownik "Elizabeth Smith" <emsmith@elizabethmariesmith.com> napisal w wiadomosci news:F4.21.17175.2E3A4E64@pb1.pair.com... > 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.

« previous php.windows (#28469) next »