0

I have a problem with memory in PHPExcel

This is the error message:

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 78 bytes) in /home/***/public_html/system/PHPExcel/Classes/PHPExcel/CachedObjectStorage/Memory.php on line 55

This is my php.ini:

magic_quotes_gpc = Off;
register_globals = Off;
default_charset = UTF-8;
memory_limit = 4096M;
max_execution_time = 36000;
upload_max_filesize = 4096M;
post_max_size = 4096M;
safe_mode = Off;
mysql.connect_timeout = 20;
session.use_only_cookies = On;
session.use_trans_sid = Off;
session.cookie_httponly = On;
session.gc_maxlifetime = 172800;
allow_url_fopen = on;
;display_errors = 1;
;error_reporting = E_ALL;

I am a newbie in PHP. Please help me, thanks very much.

sjagr
  • 15,983
  • 5
  • 40
  • 67
user3541964
  • 107
  • 2
  • 13
  • Is your Excel file bigger than 4GB? – Justinas Jan 08 '15 at 14:16
  • possible duplicate of [PHPExcel runs out of 256, 512 and also 1024MB of RAM](http://stackoverflow.com/questions/4817651/phpexcel-runs-out-of-256-512-and-also-1024mb-of-ram) – sjagr Jan 08 '15 at 14:17
  • 5
    Obviously your memory limit settings in php.ini didn't take effect, since PHP is saying the limit is 64meg (67,108,864 bytes). Did you restart PHP/webserver after changing the .ini file? Did you check if there's a memory_limit setting ELSEWHERE that's overriding the .ini version? – Marc B Jan 08 '15 at 14:17
  • Also look at [this](http://phpexcel.codeplex.com/discussions/242712?ProjectName=phpexcel) or [this](http://stackoverflow.com/questions/3537604/how-to-fix-a-memory-error-in-php) – sjagr Jan 08 '15 at 14:17
  • 1
    So read the section of the documentation about [cell caching](https://github.com/PHPOffice/PHPExcel/blob/develop/Documentation/markdown/Overview/04-Configuration-Settings.md) – Mark Baker Jan 08 '15 at 14:18
  • @Justinas : size of excel file is 451kb – user3541964 Jan 08 '15 at 14:27
  • @MarcB: I call the function echo ini_get('memory_limit'); the result is 4096M. Is there other way to check memory limit setting? – user3541964 Jan 08 '15 at 14:31
  • 1
    @user: obviously it's not, because your error says the limit is 64meg. – Marc B Jan 08 '15 at 14:32

1 Answers1

0

You can set bigger memory limit (atm it is ~64 MB, 67.11 MB)

To overrides the default PHP memory limit :

ini_set('memory_limit', '512M');

Remove limit

ini_set('memory_limit', '-1'); 
Margus
  • 19,694
  • 14
  • 55
  • 103