ID:               34112
 Updated by:       [EMAIL PROTECTED]
 Reported By:      James_Brigham at hotmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         COM related
 Operating System: Windows 2000 or Windows 2003
 PHP Version:      5.0.4
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is not something unique to COM but general 'problem' of PHP. All
memory is really cleaned up after request is ended.



Previous Comments:
------------------------------------------------------------------------

[2005-08-13 00:31:12] James_Brigham at hotmail dot com

if you comment out the query lines, then the memory leak seems to go
away...

the lines I commented out were:
//$threadRecords = $wmi->ExecQuery("SELECT * FROM
Win32_PerfRawData_PerfProc_Process WHERE Name = '" . $sProcName . "'");
//execute a wmi query against our com object
//foreach ($threadRecords as $threadcount) //loop through the resules
//{
//echo("Server:[" . $aryHost[$i] . "] Name: " . $threadcount->Name . "
Count: " . $threadcount->ThreadCount . "\r\n"); //for each result
output basic info to the screen
//}

------------------------------------------------------------------------

[2005-08-13 00:27:39] James_Brigham at hotmail dot com

As suggested, I have downloaded the latest release from:
 http://snaps.php.net/win32/php5-win32-latest.zip
and I still see the same memory leak.

------------------------------------------------------------------------

[2005-08-13 00:17:35] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2005-08-12 23:53:40] James_Brigham at hotmail dot com

Description:
------------
I have not compiled any additional modules.  The recommended default
php.ini is being used.  There is a memory leak when initiating a new
COM object, then running a query against it.  After the query even if
you use the unset()function on all the variables, you cannot recover
the full memory, it just keeps climbing.  Do you have any ideas of how
to clear the memory in this simple code I have below?

Thanks for taking the time to read this, it is appreciated.

JB


Reproduce code:
---------------
#!c:\php5\ -q
<?php

$aryHost                = array("cp2kisu01","cp2kisu02","cp2kisu03"); //this is 
a
list of servers running IIS 5 on a windows 2000 platform
$sProcName              = "dllhost"; //give the name of the process to check
$wmi                    = ""; //our comm object
$threadRecords  = ""; //comm object result set
$threadcount    = ""; //temp variable for looping though each return
record.

echo("\r\n\r\n" . str_repeat("*",79) . "\r\n");
echo("Program Start\r\n"); //this is written for command line...
echo("\r\n" . str_repeat("*",79) . "\r\n");
while(true) //loop until the end of time
{
        for ($i = 0; $i < count($aryHost); $i++) //loop through each server in
the array
        {
                $wmi = new
COM("WinMgmts:{impersonationLevel=impersonate}//{$aryHost[$i]}/root/cimv2");
//initialize new COM object
                $threadRecords = $wmi->ExecQuery("SELECT * FROM
Win32_PerfRawData_PerfProc_Process WHERE Name = '" . $sProcName . "'");
//execute a wmi query against our com object
                foreach ($threadRecords as $threadcount) //loop through the 
resules
                {
                        echo("Server:[" . $aryHost[$i] . "] Name: " . 
$threadcount->Name . "
Count: " . $threadcount->ThreadCount . "\r\n"); //for each result output
basic info to the screen
                }
                echo("\r\nClearing all the used memory for server: " . 
$aryHost[$i] .
"\r\n\r\n");
                unset($wmi); //clear object memory
                unset($threadRecords); //clear returned records memory
                unset($threadcount); //clear our temp variable we use for our 
loop
        }
        
        echo("\r\n\r\n" . str_repeat("*",79) . "\r\n");
        echo("Sleeping.. so we can check the amount of memory consumed
now..\r\n"); //this is written for command line...
        echo("\r\n" . str_repeat("*",79) . "\r\n");
        sleep(15); //sleep to keep this from being a tight loop and give time
to check the memory loss each loop
}
?>

Expected result:
----------------
D:\Appsupport\IIS_Monitor>php wmi.php


*******************************************************************************
Program Start

*******************************************************************************
Server:[cp2kisu01] Name: dllhost Count: 318
Server:[cp2kisu01] Name: dllhost Count: 10

Clearing all the used memory for server: cp2kisu01

Server:[cp2kisu02] Name: dllhost Count: 318
Server:[cp2kisu02] Name: dllhost Count: 10

Clearing all the used memory for server: cp2kisu02

Server:[cp2kisu03] Name: dllhost Count: 333
Server:[cp2kisu03] Name: dllhost Count: 10

Clearing all the used memory for server: cp2kisu03



*******************************************************************************
Sleeping.. so we can check the amount of memory consumed now..

*******************************************************************************
Server:[cp2kisu01] Name: dllhost Count: 317
Server:[cp2kisu01] Name: dllhost Count: 10

Clearing all the used memory for server: cp2kisu01

Server:[cp2kisu02] Name: dllhost Count: 310
Server:[cp2kisu02] Name: dllhost Count: 10

Clearing all the used memory for server: cp2kisu02

Server:[cp2kisu03] Name: dllhost Count: 328
Server:[cp2kisu03] Name: dllhost Count: 10

Clearing all the used memory for server: cp2kisu03



*******************************************************************************
Sleeping.. so we can check the amount of memory consumed now..

*******************************************************************************
^C
D:\Appsupport\IIS_Monitor>

Actual result:
--------------
we gets the counts expected.. but we have a memory loss every run from
this very simple script.  Basically I would like to be able to loop
this across 20 servers every 45 seconds.. but with the memory
consumption I cannot feasibly do that.  Every added server causes loss
of additional memory.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=34112&edit=1

Reply via email to