473,396 Members | 2,021 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,396 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 2732
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....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.