Jump to content

fread memory problem


shadiadiph

Recommended Posts

I am trying to fread a file that is 127,828 KB problem I am getting is I keep getting the error

 

Fatal error: Allowed memory size of 262144000 bytes exhausted (tried to allocate 130809856 bytes) in /home/myvastpl/public_html/locationimport.php on line 52

 

I have already tried ini_set('memory_limit', '150M');

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/201171-fread-memory-problem/
Share on other sites

You should run this in stages. If you're trying to create one big query then you need to remember that your memory usage will be the memory taken from the loaded file in addition to the memory usage of your query you are creating

 

Personally I would use something like fgetcsv() for this, loading in line by line and processing the data. If you're creating a query to run perhaps running them in 20 sets of data batches at a time rather than all of them at once. Also be aware of the time limit set for scripts, you will need to set the max time limit to a higher level if you've got a lot of data like this to process

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.