Page 1 of 1

Allowed Memory Size Exhausted

Posted: Thu May 09, 2002 3:05 pm
by freewholly
I am working with PHP and MySQL. I have a 12Mb file that needs to be read, parsed, processed and stored. All my code works well except at some point, I exceed the allowed memory (this is NOT a time issue). Any ideas on how I can load 12 Mb of data when the server is set to allow only 8388608 bytes?

Sample code follows:
$file = fopen("ftp://xxx:yyy@0.0.0.0:21/path/file.txt", "r");
if ($file) {
// skip first row (descriptors)
$new1 = fgets($file,3200);
while ($new1 = fgets($file,3200)) {
$line = explode ("|", $new1);
new1; // reset variable
$fields = count($line);
if($fields <= 15) {
break;
} else {
set_time_limit(0);
}
// get list
$LSID = trim($line[0]);
// etc.
$sql =
"INSERT INTO ... ( ...)" .
"values ( ... )";
$results = mysql_query($sql);
}
}
fclose($file);
}

I get about 2/3 of the way through the processing file (until my space exceeds 8.x Mb) and it bombs.

Any information is appreciated.
David

Posted: Thu May 09, 2002 5:37 pm
by DSM
Sounds like you need to reconfig the php.ini "post_max_size" to what you need to be able to run your script. 8 MB is about the norm from what I have seen.