468,140 Members | 1,626 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

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

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

Sep 8 '07 #1
9 2490
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:

<?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
Does it leak memory for every type of system call (like passthru) or
just for exec() ?

Sep 9 '07 #2
me******@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:

<?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 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.
js*******@attglobal.net
==================
Sep 9 '07 #3
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

Sep 10 '07 #4
On 9 Wrz, 16:24, Jerry Stuckle <jstuck...@attglobal.netwrote:
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:
<?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 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

Sep 10 '07 #5
me******@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.
js*******@attglobal.net
==================
Sep 10 '07 #6
me******@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.

Sep 10 '07 #7
On 10 Wrz, 21:19, Sanders Kaufman <bu...@kaufman.netwrote:
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

Sep 11 '07 #8
On Sep 11, 10:03 am, melma...@gmail.com wrote:
On 10 Wrz, 21:19, Sanders Kaufman <bu...@kaufman.netwrote:
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.

Sep 12 '07 #9

"Aaron Saray" <10********@102degrees.comwrote in message
news:11*********************@g4g2000hsf.googlegrou ps.com...
On Sep 11, 10:03 am, melma...@gmail.com wrote:
>On 10 Wrz, 21:19, Sanders Kaufman <bu...@kaufman.netwrote:
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. ;^)
Sep 12 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by José Joye | last post: by
9 posts views Thread by Anton | last post: by
3 posts views Thread by Jim Land | last post: by
2 posts views Thread by Jay | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.