Viewing objects in memory
Posted: Mon Apr 18, 2005 5:27 pm
I would like to know if it is possible to see how much memory an object created by php uses e.g.
This is merely a sample of what I am doing in my code. The problem is I loop through many records and update various other tables. To such a degree that my apache server runs constantly at 100% cpu usage. And during the update phase I can see that Mysql also uses some CPU, yet eventually the Mysql processing is dormant and the apache server continues @ full processing.
The code seems clean, and the update queries are basic. What could I be doing wrong???
Is it possible at all to see if during the process which object or process is using the most amount of memory e.g. $myClass: 123KB @ 2% CPU usage.
If the the object or process exceeds a certain amount of memory, the process could be halted to identify the culprit.
I know that a person can block off the code and debug it, but is there any such class etc
Code: Select all
$myClass = new myClass;
$myFunction = $myClass-> myFunction($parameters); // returns array of records
$myFunctionRows = $myFunction[0]["numrows"]; // returned in array
for ($i = 0; $myFunctionRows > $i; $i++) // say 20000 records
{
$myVar = $myFunction[$i]["myVar"];
$myClass-> updateFunction($myVar); // simple update query
} //for ($i = 0; $myFunctionRows > $i; $i++)This is merely a sample of what I am doing in my code. The problem is I loop through many records and update various other tables. To such a degree that my apache server runs constantly at 100% cpu usage. And during the update phase I can see that Mysql also uses some CPU, yet eventually the Mysql processing is dormant and the apache server continues @ full processing.
The code seems clean, and the update queries are basic. What could I be doing wrong???
Is it possible at all to see if during the process which object or process is using the most amount of memory e.g. $myClass: 123KB @ 2% CPU usage.
If the the object or process exceeds a certain amount of memory, the process could be halted to identify the culprit.
I know that a person can block off the code and debug it, but is there any such class etc