PHPExcel Writer Excel2007 error - php

I recently encountered this error in my report.
PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 3022731 bytes)
I cant seem to resolved the problem, i already added:
set_time_limit(0);
ini_set('memory_limit', -1);
in my script but it seems the issue is still persistent, by the way im using
PHPExcel ver 1.7.6
My excel file output contains 55 headers and multiple worksheets (closely 45 - increasing) and each sheet contains about 150 to 500 records
I would like to seek for your help and advises to resolve my remedy T_T
Thanks!

I would suggest to import the Excel File into an Access Database and then query the database via ODBC from PHP.

Maybe try using the https://github.com/PHPOffice/PhpSpreadsheet - it`s the rewritten version of PhpExcel. It works way better. I know, because I have used both.
If that does not help your problem you should use caching see: https://phpspreadsheet.readthedocs.io/en/develop/topics/memory_saving/
P.S. if you will be using sqlite3 caching make sure you have the proper extension php-sqlite3 installed, because it fails silently and does not cache if extension is not there.

Related

Allowed memory size error in Tbs library

Hello i am facing the problem of Allowed memory size error. I have created the project in codeigniter, php and I have used Tbs library. Its worked fine but today it display the error:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 258010 bytes) in
/home/abc/public_html/application/libraries/Tbs.php on line
4222
Please give me any suggestions.
If you are using TBS + OpenTBS in order to merge an XLSX file , then there is a known problem fixed with OpenTBS version 1.9.2 : if the number of row to merge is quite numerous, then you can have a very long process or a memory size error when calling $TBS->Show().
Use OpenTBS 1.9.2 or higher which is optimized for this point, and if the process is still long you can optimize more using the OPENTBS_RELATIVE_CELLS command.
"Allowed memory size of XXXXXX bytes exhausted" is a typical error when you don't have, as it's own name says, enough memory available for the php query to run.
Try upgrading memory_limit variable on your php.ini file, or by setting up ini_set('memory_limit', 'XXXM'); on your PHP file that you are running, being XXX the amount of Mb memory that you want to define.
If this isn't the case, you might have a bug in your software that is causing, i.e. a loop that is consuming memory without any control; but as you have said that it did work before...
Anyway, please check all the other answers from StackOverflow on this aspect:
Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)
CodeIgniter Fatal error: Allowed memory size of bytes exhausted
Codeigniter - Allowed memory size exhausted while uploading
Generally this type of occurs when your script is using too much memory. This can often happen in PHP if you have a loop that has run out of control and you are creating objects or adding to arrays on each pass of the loop. Check for infinite loops.
If that isn't the problem, try and help out PHP by destroying objects that you are finished with by setting them to null eg. $OldVar = null;.
Check the code where the error actually happens as well. Would you expect that line to be allocating a massive amount of memory? If not, try and figure out what has gone wrong.
Never upgrad memory_limit variable on your php.ini file, or by setting up ini_set('memory_limit', 'XXXM'); on your PHP file that you are running, being XXX the amount of Mb memory that you want to define.Letting application to eat memory he wants to is insane step.Try to find out bug does your application wants that much memory?? Find out

Wordpress Dies When trying to edit the homepage

The problem is very very weird. Let me explain a little bit better - We have a multi site built for the client. Until recently we could edit the homepage with no issues. In the meantime we have upgraded the core (it was still working with new core). Just recently whenever I try to edit the homepage I get this error
Fatal error: Out of memory (allocated 42467328) (tried to allocate 64 bytes) in /home/officete/public_html/wp-includes/wp-db.php on line 1557
Ok so the apparent solution was to change the php memory allowance... Well I have increased it on the server via WHM, increased it in htaccess, wp-config and php.ini file to over 1.2GB (never really expected I will have to increase it so much) just for testing reasons. Every time I try to edit the page I get the same god damn error and 42467328 allocation limit doesn't change at all the " 64 bytes" part does though and its between 32-128 bytes so far.
I am stumped. And have no idea what else I can do. I did contact the server provider they say it looks ok from their end.
I am assuming its the amount of data that is being collected it does contain few ACF repeater fields (15 of them... I know... But I haven't built it). I did disable all the plugins the error persists (I know that disabling them don't really change what is being pulled from db).
BTW The line 1557 is the return result function that returns the query in an array.
you page need more execution time.add below code into config file and try:
define('WP_MEMORY_LIMIT', '128M');

MySQL db export: Allowed memory size of 67108864 bytes exhausted

First off, this issue has been stated on StackOverflow many times, but not where I am seeing the error. I've read through every one to make sure this is not a duplicate. Issue is occurring when I try to export a database from phpMyAdmin so that I can import it to another server. The .sql file is saving, but the last line shows the following error message.
Environment:
MediaTemple Grid Server (gs)
Wordpress plugin with MySQL database
Exporting using phpMyAdmin
Error message:
<b>Fatal error</b>: Allowed memory size of 67108864 bytes exhausted (tried to allocate 22505404 bytes) in <b>.../phpMyAdmin/current/libraries/export/sql.php</b> on line <b>1255</b><br />
PHP settings:
I have run the command: ini_set('memory_limit', '128M');, and phpinfo() shows memory_limit: 128M.
Everywhere that I have read, this is a PHP error. Could it have anything to do with MySQL variables?
Thanks in advance for your time and help!
No, it is most definitely a PHP error, probably stemming from a setting in PhpMyAdmin.
Have you tried doing a mysqldump on the command line?

memory limit in php

I'm making a curl request , witch was working perfectly for weeks, and now it's returning this error:
Allowed memory size of 262144 bytes exhausted (tried to allocate 76889 bytes)
The weird part is that i've checked php.ini and phpinfo and both tell me memory limit is
memory_limit 1028M
I've also tried
ini_set("memory_limit","400M");
In the top of the file to make sure, but still, getting this error.
This is happening in both development and production servers.
DaveRandom nailed it. suhosin (I wasn't even aware we had that
installed) was causing de issue by "overprotecting" the server.
[forums.cpanel.net/f5/php-memory-limit-problem-69715.html][1] - TL;DR
it's being caused by suhosin. – DaveRandom
Thanks to all!
[1]: http://forums.cpanel.net/f5/php-memory-limit-problem-69715.html
UPS, that somehow fiexd the error in that part, but another part of the webapp is throwing same error.
I have no clue where to look at.
it says memory limit is 1028M in php info, if i change it via ini_set, new value appears using ini_get, and now I have set suhosin to simulation. that somehow fixed the first problem, but now it reappeared.

Kohana and Simple HTML Dom parser are having issues

Trying to use the Simple HTML Dom Parser in my application.
Placed the sample function of scraping_slashdot() into a controller.
include_once('includes/simple_html_dom.php');
$ret = $this->scraping_slashdot();
print_r($ret);
Get:
ErrorException [ Fatal Error ]: Allowed memory size of 134217728 bytes exhausted (tried to allocate 291337 bytes)
The thing is that when I do the exact same thing in a stand-alone file (not as a part of a Ko app), everything seems to work just fine.
Does anyone have any idea what it could be?
PS
Using Ko 3.2, haven't tried other versions, though I've used this class in 3.0 before just fine.
Your script is trying to allocate more memory then allowed. Try using a profiler (Xdebug) to see where does the leak come from or use workaround solution - ini_set('memory_limit', '-1') or set it directly in php.ini if you have access.

Categories