473,587 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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<100 0;$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 2738
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<100 0;$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<100 0;$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*******@attgl obal.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...@attg lobal.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<100 0;$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...@attgl obal.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*******@attgl obal.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********@102 degrees.comwrot e in message
news:11******** *************@g 4g2000hsf.googl egroups.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
4656
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 -AA flag. In another news group I came across some interesting (ok scarey) information regarding memory leaks in the STL list<...> container. I...
8
4743
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 least)...the subject is "4 GB hard constraint on a Solaris 8 server". I figured I'd post over here because we aren't getting anywhere too fast over...
17
4786
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 easier to reproduce (e.g.: remote machine not available). After about 1 day, I get a usage of 300MB of memory. I have used .NET Memory Profiler tool to...
25
2358
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 memory profile shows that those instances survive 3 rounds of GC collections - it's not what I expected. In my real code, CMyClass occupies big...
9
425
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 which application and which dll and asmx page that cause the problem. {Rheena} May I know what operating system you are using?
1
1707
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 (discovered using a memory profiler) is that the base exception being thrown in the collection is not being disposed of. I understand about the GC etc...
35
5485
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 indeed fixed. Being in a hurry, I originally used a q&d hack...: if sys.platform in ('linux2', 'darwin'): def _memsize(): """ this function...
3
5303
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". Anybody know anything about this? Does *Javascript* leak memeory, or does the *browser* leak memory?
2
2692
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. I looked at the memory and it seems to be full. I removed all the javascript code - and the app seems to be have no leaks. As soon as I include my...
0
7918
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6621
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5392
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.