Link to home
Start Free TrialLog in
Avatar of ncw
ncw

asked on

Fatal error: Allowed memory size

I'm using a php script to open and read a data file using function fgetcsv; this works for data files up to the size of about 6MB but fails with a file of 7.98MB. I realise the default memory_size is 8MB and I'm wanting to open a 22MB text data file on the webserver. I've tried increasing the memory_size using both of the following techniques:

ini_set("memory_limit","50M");  -  placed at the top of the script file

php_value memory_limit "50M"  - placed in an .htaccess file

Both of these methods seem to cause the error message to register the increase, but it still fails. A typical error message:

Fatal error: Allowed memory size of 52428800 bytes exhausted (tried to allocate 31 bytes) in /home/account/public_html/directory/functions.php on line 117

Looking for some specific advice please, not links to other questions unless they have info specific to my problem. Maybe there's a better way to read the csv file, or read it in stages (line by line would take a long time there's 15000 records).

ASKER CERTIFIED SOLUTION
Avatar of limneos
limneos

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ncw
ncw

ASKER

Success!  ini_set("memory_limit","-1"); worked.

Fantastic, thank you.
You're always welcome ;-)