SegFault with PHP or PEAR::SOAP
| From: | David Busby | Date: | Fri, 10 Jan 2003 02:39:38 +0000 |
| Subject: | SegFault with PHP or PEAR::SOAP | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-389@lists.php.net to get a copy of this message | ||
List,
Does anyone know how to attach a debugger to a running process?
I've got this fun PHP script that uses PEAR::SOAP to interact with another
database my company has.
The "other" database (which is being phased out) is M$-SQL 2000. To get to
the Database I wrote a simple SOAP page on an IIS server which allows me to
execute SQL statements aginst the DB. I've got to import some records from
the DB, so I make a query. There are 2659 records to import. That was too
many for either PHP/PEAR::SOAP or IIS to handle and the query would fail, if
I tried to grab them all.
So I did it by month, and get this:
Requesting 1/2003...550 items
Requesting 2/2003...500 items
Requesting 3/2003...623 items
Requesting 4/2003...326 items
Requesting 5/2003...160 items
Requesting 6/2003...140 items
Requesting 7/2003...118 items
Requesting 8/2003...143 items
Requesting 9/2003...94 items
Requesting 10/2003...48 items
Requesting 11/2003...26 items
Requesting 12/2003...1 items
Requesting 1/2004...1 items
[ Now I've seen many error messages]
[ One ]
Requesting 2/2004...Segementation Fault
[ Two ]
Requesting 2/2004...
Notice: Undefined property: _debug in /usr/local/lib/php/PEAR.php on line
143
Notice: Undefined property: fault in /usr/local/lib/php/SOAP/Client.php on
line 223
Fatal error: Call to undefined function: send() in
/usr/local/lib/php/SOAP/Client.php on line 228
Segmentation fault
[ Three ]
Requesting 2/2004...FATAL: emalloc(): Unable to allocate 908996661 bytes
Look what TOP says (SIZE!, %MEM!):
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
30118 root 19 0 78836 76M 2004 R 9.1 30.7 0:53 import-items-f
The response for 2/2004 has one item in it, but why does it segfault? I'd
post the code but I'm concerned about showing any info about my datbases,
I'll see what I can do. In the mean time, I've watched the wire and nothing
seems out of the ordinary as far as what is transfering, all nicely formed
XML. I notice that the script continues to consume memory, even though I
unset() both the soap client, and the response. What I'm saying is that I
create a new SOAP/Client for each iteration of the loop (36 iterations).
Shouldn't memory be freed? The script consumes lots of memory at the time
of the SegFault. Heres where it gets even better, if I cut out the first
year (2003), the script runs fine for the next 24 iterations, so it seems
like either unset() or SOAP/Client is not letting go of something?
At the end of each loop I do ($sc is client, $items is response):
$items = $sc->call('exec_sql', $params, $options);
$c = count($items);
echo "$c items\r\n";
unset ($sc);
unset ($items);
Shouldn't that free up some memory? Doesn't look like it is.
Workaround: a BASH script that calls the PHP script with a year parameter is
my solution,
call the script with the year, do one iteration for each month, exit (free
memory), call script again for next year.
I know there are other ways to do this, but this way is more fun. I would
like to know why the SegFault though.
TIA
David Busby
Systems Engineer
busby@pnts.com