Fatal error: Allowed memory size ... exhausted (code inside)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dd3123
Forum Newbie
Posts: 1
Joined: Tue Oct 15, 2002 1:58 pm

Fatal error: Allowed memory size ... exhausted (code inside)

Post by dd3123 »

Ok, here's the small block of code so far, and $contents holds a comma delimited file's contents (clever huh):


...

$contentlines = explode("\n" , $contents);
unset($contents);
while(list($key, $value) = each($contentlines))
{

$contentarray = explode("," , $value);
list($tracking, $email, $orderid) = $contentarray;
{
$ups = new ssl_ups("$upskey", "$upsid", "$upspass");
$ups->SetUrl("https://www.ups.com/ups.app/xml/Track");
$ups->Post("$tracking");
if ($ups->GetStatus() == "done")
{
$result = $ups->GetResultArray();
while(list($key2, $value2) = each($result))
{
echo "[$key2] => $value2<br>\n";
}
}
unset($ups);
flush();
}
}

...


My problem is, on my 30th post to the server, I run out of memory when XPath (an XML class which is used by my UPS class) looks at the results (which are no bigger than any previous results). I would have thought that unset would have freed up my previously used memory in $ups?

Any thoughts on how to get this to work past 30?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

consider using

Code: Select all

$fd = fopen('the.file', 'r');
while($value = fgets($fd, 1024) )
{ ...
if you think there is a memory-hole in PHP/XSLT/XML-implementation try to track it down and post a bug report ;)

btw: welcome Image
Post Reply