473,233 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,233 software developers and data experts.

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 2723
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeremy Lemaire | last post by:
Hello, I am working on cross platform code that is displaying a huge memory leak when compiled on 11.00 HPUX using the aCC -AA flag. It is not leaking on NT, LINUX, Solaris, or HPUX without the...
8
by: clsmyth | last post by:
Folks, Hi, I have never posted to a language group before so please excuse me if this is inappropriate. I have posted this to comp.unix.solaris (well, I am one of the folks on the thread at...
17
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
25
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My...
9
by: Anton | last post by:
{Willy Skjveland} Hi, how can I trace a Memory leak in aspnet_wp.exe? {Rheena} One moment please while I search it for you. It may take me a few moments {Willy Skjveland} I need to find out...
1
by: bw | last post by:
I have a basic custom collection that throws a new exception if the item(key) is not found in the collection. This is used as part of a calling function. It all works correctly, the problem...
35
by: Alex Martelli | last post by:
Having fixed a memory leak (not the leak of a Python reference, some other stuff I wasn't properly freeing in certain cases) in a C-coded extension I maintain, I need a way to test that the leak is...
3
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
2
by: Jay | last post by:
I have a web app running on the windows CE device. In one of the asp.net pages - it has javascript code. That seems to have a memory leak. When I run the web app - in about one hour, the app hangs....
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.