php-windows Digest 12 Sep 2007 01:11:49 -0000 Issue 3329

Topics (messages 28471 through 28479):

Re: Memory leak occurs when exec() function is used on Windows platform
        28471 by: Gustav Wiberg
        28478 by: Melmack
        28479 by: Leo G. Divinagracia III

Re: File-error code?
        28472 by: Gustav Wiberg
        28476 by: John Mertic

Question about office web component
        28473 by: watersniper
        28474 by: Stut
        28475 by: watersniper
        28477 by: Stut

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi!

Can't you just test if the file contains anything, and if it doesn THEN run 
exec-command?

Best regards
/Gustav Wiberg
 

-----Original Message-----
From: Melmack [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 10, 2007 8:17 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Re: Memory leak occurs when exec() function is used on 
Windows platform

Thank you for your reply.
Unfortunately your method also causes memory leak.
I have tested operating system and I have discovered
that batch script listed below causes the same memory leak.
That is why I think now that it is however not PHP fault but Windows bug.

The Windows batch script contains:
for /L %%i in (1,1,500) do cmd /C test.bat

where test.bat is just an empty file.

Maybe someone knows how to solve this problem?

Best regards
Melmack


Uzytkownik "Elizabeth Smith" <[EMAIL PROTECTED]> napisal w 
wiadomosci news:[EMAIL PROTECTED]
> melmack 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've found exec to be flaky enough on windows that instead I use com to 
> spawn the new process.
>
> $shell = new COM('WScript.Shell');
> $return = $shell->Run($cmd, 0, false);
> unset ($shell);
>
> Faster and no leaks ;)  Only downside is you have to wrap cross-platform 
> code with windows detection. 

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 2007-09-09 
10:17
 

--- End Message ---
--- Begin Message ---
""Melmack"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Thank you for your reply.
> Unfortunately your method also causes memory leak.
> I have tested operating system and I have discovered
> that batch script listed below causes the same memory leak.
> That is why I think now that it is however not PHP fault but Windows bug.
>
> The Windows batch script contains:
> for /L %%i in (1,1,500) do cmd /C test.bat
>
> where test.bat is just an empty file.
>
> Maybe someone knows how to solve this problem?
>
> Best regards
> Melmack
>
>
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

--- End Message ---
--- Begin Message ---
hmmmm...

just tested it on my box: win xp sp2, apache 2.2.2, php 5.1.4 and 1gb of ram. ran it under CLI.

copied your code and and created a 0 btye test.bat file.

rebooted the machine so a fresh start.

first time, i actually gained 3 megs of ram back, after the process timed out after 60 seconds.

second time, after timing out, came back to same amount.


melmack 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

--- End Message ---
--- Begin Message ---
Hi!

I have solved the problem, but I just wondered if there were any options. I use 
@scandir, and when no error occurs then it shows folders from the specified 
folder in scandir-function. But this doesn't seem like "good" programming 
practice... ;-)

Best regards
/Gustav Wiberg
 

-----Original Message-----
From: John Mertic [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 10, 2007 4:14 PM
To: Gustav Wiberg
Cc: php windows
Subject: Re: [PHP-WIN] File-error code?

For the most part yes. Please elaborate if there is something
particular you are looking for?

John

On 9/10/07, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> Hi!
>
> Ok. That is the only option then?
>
> Best regards
> /Gustav Wiberg
>
>
> -----Original Message-----
> From: John Mertic [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 10, 2007 2:10 PM
> To: Gustav Wiberg; php windows
> Subject: Re: [PHP-WIN] File-error code?
>
> You can use is_file() and is_readable() to determine if the file
> exists and is readable. That's not really getting you any sort of
> "error code", but it least it helps narrow things down.
>
> John
>
> On 9/10/07, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> > Hi!
> >
> > Yes, that's correct.
> >
> > Best regards
> > /Gustav Wiberg
> >
> >
> > -----Original Message-----
> > From: John Mertic [mailto:[EMAIL PROTECTED]
> > Sent: Monday, September 10, 2007 1:55 PM
> > To: Gustav Wiberg
> > Subject: Re: [PHP-WIN] File-error code?
> >
> > I guess my question is from where  ( HTTP error code, etc ) and what
> > choices are you looking for in terms of a sub code ( file not found,
> > not readable, etc ).
> >
> > On 9/10/07, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> > > Permission denied
> > >
> > > Best regards
> > > /Gustav Wiberg
> > >
> > >
> > > -----Original Message-----
> > > From: John Mertic [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, September 10, 2007 1:30 PM
> > > To: Gustav Wiberg
> > > Subject: Re: [PHP-WIN] File-error code?
> > >
> > > Hi,
> > >
> > > What code are you looking for?
> > >
> > > John
> > >
> > > On 9/10/07, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> > > > Hi!
> > > >
> > > > I test using readfile($filename) and that's ok. When I'm logged in with 
> > > > "incorrect user" I get permission denied... Is there any way of 
> > > > retrieving the "permission denied" code? when using readfile? (or any 
> > > > other error regarding to readfile-function?
> > > >
> > > > Best regards
> > > > /Gustav Wiberg
> > > >
> > > > No virus found in this outgoing message.
> > > > Checked by AVG Free Edition.
> > > > Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 
> > > > 2007-09-09 10:17
> > > >
> > > >
> > > > --
> > > > PHP Windows Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > > >
> > >
> > >
> > > --
> > > --
> > > John Mertic                                        "Explaining a joke
> > > is like dissecting a frog: you
> > > [EMAIL PROTECTED]                              understand it better,
> > > but the frog dies in the
> > >                                                           process."
> > >
> > >                       -Mark Twain
> > >
> > > No virus found in this outgoing message.
> > > Checked by AVG Free Edition.
> > > Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 
> > > 2007-09-09 10:17
> > >
> > >
> > >
> > >
> >
> >
> > --
> > --
> > John Mertic                                        "Explaining a joke
> > is like dissecting a frog: you
> > [EMAIL PROTECTED]                              understand it better,
> > but the frog dies in the
> >                                                           process."
> >
> >                       -Mark Twain
> >
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 2007-09-09 
> > 10:17
> >
> >
> >
> >
>
>
> --
> --
> John Mertic                                        "Explaining a joke
> is like dissecting a frog: you
> [EMAIL PROTECTED]                              understand it better,
> but the frog dies in the
>                                                           process."
>
>                       -Mark Twain
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 2007-09-09 
> 10:17
>
>
>
>


-- 
-- 
John Mertic                                        "Explaining a joke
is like dissecting a frog: you
[EMAIL PROTECTED]                              understand it better,
but the frog dies in the
                                                          process."

                      -Mark Twain

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 2007-09-09 
10:17
 

--- End Message ---
--- Begin Message ---
Yeah, that's kinda of heavyweight solution to the problem ( not to
mention is much slower than using opendir(), readdir(), and closedir()
since scandir() sorts the results as well ).

If you are just checking for access, either opendir() or is_readable()
should work much faster. But I guess I don't really understand the
context of your issue either, which may dictate why one way of doing
things might be better than another.

John

On 9/11/07, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I have solved the problem, but I just wondered if there were any options. I 
> use @scandir, and when no error occurs then it shows folders from the 
> specified folder in scandir-function. But this doesn't seem like "good" 
> programming practice... ;-)
>
> Best regards
> /Gustav Wiberg
>
>
> -----Original Message-----
> From: John Mertic [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 10, 2007 4:14 PM
> To: Gustav Wiberg
> Cc: php windows
> Subject: Re: [PHP-WIN] File-error code?
>
> For the most part yes. Please elaborate if there is something
> particular you are looking for?
>
> John
>
> On 9/10/07, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> > Hi!
> >
> > Ok. That is the only option then?
> >
> > Best regards
> > /Gustav Wiberg
> >
> >
> > -----Original Message-----
> > From: John Mertic [mailto:[EMAIL PROTECTED]
> > Sent: Monday, September 10, 2007 2:10 PM
> > To: Gustav Wiberg; php windows
> > Subject: Re: [PHP-WIN] File-error code?
> >
> > You can use is_file() and is_readable() to determine if the file
> > exists and is readable. That's not really getting you any sort of
> > "error code", but it least it helps narrow things down.
> >
> > John
> >
> > On 9/10/07, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> > > Hi!
> > >
> > > Yes, that's correct.
> > >
> > > Best regards
> > > /Gustav Wiberg
> > >
> > >
> > > -----Original Message-----
> > > From: John Mertic [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, September 10, 2007 1:55 PM
> > > To: Gustav Wiberg
> > > Subject: Re: [PHP-WIN] File-error code?
> > >
> > > I guess my question is from where  ( HTTP error code, etc ) and what
> > > choices are you looking for in terms of a sub code ( file not found,
> > > not readable, etc ).
> > >
> > > On 9/10/07, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> > > > Permission denied
> > > >
> > > > Best regards
> > > > /Gustav Wiberg
> > > >
> > > >
> > > > -----Original Message-----
> > > > From: John Mertic [mailto:[EMAIL PROTECTED]
> > > > Sent: Monday, September 10, 2007 1:30 PM
> > > > To: Gustav Wiberg
> > > > Subject: Re: [PHP-WIN] File-error code?
> > > >
> > > > Hi,
> > > >
> > > > What code are you looking for?
> > > >
> > > > John
> > > >
> > > > On 9/10/07, Gustav Wiberg <[EMAIL PROTECTED]> wrote:
> > > > > Hi!
> > > > >
> > > > > I test using readfile($filename) and that's ok. When I'm logged in 
> > > > > with "incorrect user" I get permission denied... Is there any way of 
> > > > > retrieving the "permission denied" code? when using readfile? (or any 
> > > > > other error regarding to readfile-function?
> > > > >
> > > > > Best regards
> > > > > /Gustav Wiberg
> > > > >
> > > > > No virus found in this outgoing message.
> > > > > Checked by AVG Free Edition.
> > > > > Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 
> > > > > 2007-09-09 10:17
> > > > >
> > > > >
> > > > > --
> > > > > PHP Windows Mailing List (http://www.php.net/)
> > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > --
> > > > John Mertic                                        "Explaining a joke
> > > > is like dissecting a frog: you
> > > > [EMAIL PROTECTED]                              understand it better,
> > > > but the frog dies in the
> > > >                                                           process."
> > > >
> > > >                       -Mark Twain
> > > >
> > > > No virus found in this outgoing message.
> > > > Checked by AVG Free Edition.
> > > > Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 
> > > > 2007-09-09 10:17
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > --
> > > John Mertic                                        "Explaining a joke
> > > is like dissecting a frog: you
> > > [EMAIL PROTECTED]                              understand it better,
> > > but the frog dies in the
> > >                                                           process."
> > >
> > >                       -Mark Twain
> > >
> > > No virus found in this outgoing message.
> > > Checked by AVG Free Edition.
> > > Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 
> > > 2007-09-09 10:17
> > >
> > >
> > >
> > >
> >
> >
> > --
> > --
> > John Mertic                                        "Explaining a joke
> > is like dissecting a frog: you
> > [EMAIL PROTECTED]                              understand it better,
> > but the frog dies in the
> >                                                           process."
> >
> >                       -Mark Twain
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 2007-09-09 
> > 10:17
> >
> >
> >
> >
>
>
> --
> --
> John Mertic                                        "Explaining a joke
> is like dissecting a frog: you
> [EMAIL PROTECTED]                              understand it better,
> but the frog dies in the
>                                                           process."
>
>                       -Mark Twain
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.485 / Virus Database: 269.13.12/997 - Release Date: 2007-09-09 
> 10:17
>
>
>
>


-- 
-- 
John Mertic                                        "Explaining a joke
is like dissecting a frog: you
[EMAIL PROTECTED]                              understand it better,
but the frog dies in the
                                                          process."

                      -Mark Twain

--- End Message ---
--- Begin Message ---
Hello!
How can I use OWC with PHP?

Thanks! 

--- End Message ---
--- Begin Message ---
watersniper wrote:
How can I use OWC with PHP?

I've never tried it but I see no reason why not. You'll need to use the COM extension: http://php.net/com

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Stut,Thank you very much!

But I don't know --the module_name
 in  COM::COM ( string $module_name )
And, I can't find how to operate the object.
 

--- End Message ---
--- Begin Message ---
watersniper wrote:
Stut,Thank you very much!

But I don't know --the module_name
 in  COM::COM ( string $module_name )
And, I can't find how to operate the object.

That bit doesn't have much to do with PHP. You need to read the documentation for the office web components.

-Stut

--
http://stut.net/

--- End Message ---

Reply via email to