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
Share on other sites

Is there any reason why you need the whole of this file imported at once? what sort of file is it (ie what are you wanting to do with the data). If you change the size to a bigger memory limit it will probably work, but you shouldn't have to do that

Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.