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

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

am 08.09.2007 18:37:40 von melmack3

Hi

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


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

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

am 09.09.2007 16:05:16 von Aaron Saray

On Sep 8, 11:37 am, melma...@gmail.com wrote:
> Hi
>
> I have a big problem with shell commands execution via PHP.
> I have written a very short PHP script ilustrating the problem:
>
> >
> 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

Does it leak memory for every type of system call (like passthru) or
just for exec() ?

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

am 09.09.2007 16:24:24 von Jerry Stuckle

melmack3@gmail.com wrote:
> Hi
>
> I have a big problem with shell commands execution via PHP.
> I have written a very short PHP script ilustrating the problem:
>
> >
> 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 see it increase on my W2K system, but as soon as the program ends, the
memory allocation goes back to what it was. Are you sure it isn't just
the gc not having a chance to run?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

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

am 10.09.2007 20:19:14 von melmack3

> Does it leak memory for every type of system call (like passthru) or
> just for exec() ?- Ukryj cytowany tekst -
>
> - Poka cytowany tekst -

I have tested exec, system, popen, shell_exec functions. Nothing works
correctly. I have also tested Windows script:

for /L %%i in (1,1,500) do cmd /C test.bat

where test.bat is just an empty file

It causes similar memory leak effect, so I think now that it is
however not PHP fault but Windows bug.

Maybe someone knows how to solve this problem?

Best regards
Melmack

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

am 10.09.2007 20:22:14 von melmack3

On 9 Wrz, 16:24, Jerry Stuckle wrote:
> melma...@gmail.com wrote:
> > Hi
>
> > I have a big problem with shell commands execution via PHP.
> > I have written a very short PHP script ilustrating the problem:
>
> > >
> > 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 see it increase on my W2K system, but as soon as the program ends, the
> memory allocation goes back to what it was. Are you sure it isn't just
> the gc not having a chance to run?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================- Ukryj cytowany tekst -
>
> - Poka cytowany tekst -

I have used sessions and forced garbage collector
to clean the memory with the probability 100%
(reconfiguring php.ini file)
and I called this script X times. The memory was not freed at all!

But I have discovered that it is Windows bug (see my reply to Aaron)

Thank you
Best regards
Melmack

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

am 10.09.2007 21:03:09 von Jerry Stuckle

melmack3@gmail.com wrote:
>> Does it leak memory for every type of system call (like passthru) or
>> just for exec() ?- Ukryj cytowany tekst -
>>
>> - Poka cytowany tekst -
>
> I have tested exec, system, popen, shell_exec functions. Nothing works
> correctly. I have also tested Windows script:
>
> for /L %%i in (1,1,500) do cmd /C test.bat
>
> where test.bat is just an empty file
>
> It causes similar memory leak effect, so I think now that it is
> however not PHP fault but Windows bug.
>
> Maybe someone knows how to solve this problem?
>
> Best regards
> Melmack
>

Switch to Linux.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

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

am 10.09.2007 21:19:30 von Bucky Kaufman

melmack3@gmail.com wrote:

> I have used sessions and forced garbage collector
> to clean the memory with the probability 100%
> (reconfiguring php.ini file)
> and I called this script X times. The memory was not freed at all!
>
> But I have discovered that it is Windows bug (see my reply to Aaron)

In the Zend Platform docs, they point out that while Windows servers are
adequate for most development, they should not be used for production.

This shell problem is exactly why.

This same bug is why Windows became such a target for viruses - the real
ones, not the scripties.

Those Seattle Republicans play fast-and-loose with memory management.

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

am 11.09.2007 17:03:25 von melmack3

On 10 Wrz, 21:19, Sanders Kaufman wrote:
> melma...@gmail.com wrote:
> > I have used sessions and forced garbage collector
> > to clean the memory with the probability 100%
> > (reconfiguring php.ini file)
> > and I called this script X times. The memory was not freed at all!
>
> > But I have discovered that it is Windows bug (see my reply to Aaron)
>
> In the Zend Platform docs, they point out that while Windows servers are
> adequate for most development, they should not be used for production.
>
> This shell problem is exactly why.
>
> This same bug is why Windows became such a target for viruses - the real
> ones, not the scripties.
>
> Those Seattle Republicans play fast-and-loose with memory management.

After long hours of fighting and testing I have fixed the problem.
It was caused by an additional firewall installed on both computers
used by me for testing process. When I uninstalled it memory leak
disappeared.

Thanks all for help.
Best regards
Melmack

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

am 12.09.2007 04:15:48 von Aaron Saray

On Sep 11, 10:03 am, melma...@gmail.com wrote:
> On 10 Wrz, 21:19, Sanders Kaufman wrote:
>
>
>
> > melma...@gmail.com wrote:
> > > I have used sessions and forced garbage collector
> > > to clean the memory with the probability 100%
> > > (reconfiguring php.ini file)
> > > and I called this script X times. The memory was not freed at all!
>
> > > But I have discovered that it is Windows bug (see my reply to Aaron)
>
> > In the Zend Platform docs, they point out that while Windows servers are
> > adequate for most development, they should not be used for production.
>
> > This shell problem is exactly why.
>
> > This same bug is why Windows became such a target for viruses - the real
> > ones, not the scripties.
>
> > Those Seattle Republicans play fast-and-loose with memory management.
>
> After long hours of fighting and testing I have fixed the problem.
> It was caused by an additional firewall installed on both computers
> used by me for testing process. When I uninstalled it memory leak
> disappeared.
>
> Thanks all for help.
> Best regards
> Melmack

What firewalls were they? I haven't thought about that - heh - its
been such a long time since I thought about those (about 2 years when
I used to work at an ISP). I guess that makes sense... with either a
virus protection program or a firewall - they're going to scan spawned
processes... but woudln't it be the a/v or firewall process that gets
the memory spike? Any other details would be cool - I'm rather
curious now.

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

am 12.09.2007 05:07:07 von Steve

"Aaron Saray" <102degrees@102degrees.com> wrote in message
news:1189563348.374623.57660@g4g2000hsf.googlegroups.com...
> On Sep 11, 10:03 am, melma...@gmail.com wrote:
>> On 10 Wrz, 21:19, Sanders Kaufman wrote:
>>
>>
>>
>> > melma...@gmail.com wrote:
>> > > I have used sessions and forced garbage collector
>> > > to clean the memory with the probability 100%
>> > > (reconfiguring php.ini file)
>> > > and I called this script X times. The memory was not freed at all!
>>
>> > > But I have discovered that it is Windows bug (see my reply to Aaron)
>>
>> > In the Zend Platform docs, they point out that while Windows servers
>> > are
>> > adequate for most development, they should not be used for production.
>>
>> > This shell problem is exactly why.
>>
>> > This same bug is why Windows became such a target for viruses - the
>> > real
>> > ones, not the scripties.
>>
>> > Those Seattle Republicans play fast-and-loose with memory management.
>>
>> After long hours of fighting and testing I have fixed the problem.
>> It was caused by an additional firewall installed on both computers
>> used by me for testing process. When I uninstalled it memory leak
>> disappeared.
>>
>> Thanks all for help.
>> Best regards
>> Melmack
>
> What firewalls were they? I haven't thought about that - heh - its
> been such a long time since I thought about those (about 2 years when
> I used to work at an ISP). I guess that makes sense... with either a
> virus protection program or a firewall - they're going to scan spawned
> processes... but woudln't it be the a/v or firewall process that gets
> the memory spike? Any other details would be cool - I'm rather
> curious now.

that is curious!

hey, remember win NT 4? you could run the processor and memory up to 100%
just by holding down the mouse button on the desktop? ah the days. ;^)