Backup problem: "Fatal error: Allowed memory..." - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Backup problem: "Fatal error: Allowed memory..." (/showthread.php?tid=29386) |
Backup problem: "Fatal error: Allowed memory..." - El Forum - 04-08-2010 [eluser]ministry[/eluser] Hi. I'm trying to backup my entire database, but I get this message: Quote:Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 10755665 bytes) in /web/htdocs/www.mydomain.it/home/system/libraries/Zip.php on line 160 I did my last working backup yesterday; so it seems the last inserted queries have exceded the allowed database size; at the moment its size is about 2.5mb. How can I increase the limit? By the way, my code is very simple: Code: $this->load->dbutil(); Backup problem: "Fatal error: Allowed memory..." - El Forum - 04-08-2010 [eluser]AgentPhoenix[/eluser] It's not that the database is too large, but that PHP's memory limit is too low in order to execute the script. You can change it using ini_set() or change your PHP's php.ini file to set a higher memory limit. Backup problem: "Fatal error: Allowed memory..." - El Forum - 04-09-2010 [eluser]ministry[/eluser] ini_set() did the trick! Thank you very much! Backup problem: "Fatal error: Allowed memory..." - El Forum - 06-01-2010 [eluser]TheoR74[/eluser] I am having a problem like this. I have a script running at the prompt accepting data and writing it to a database. It seems if I comment out the db->insert commands, it doesn't have any memory issues, only on those commands. So, I'm wondering, is there something in that command that isn't freeing up memory? Or a variable that isn't getting cleared out where the multiple insert commands are too much for it? I looked at the db->insert code but kinda got lost. Backup problem: "Fatal error: Allowed memory..." - El Forum - 06-01-2010 [eluser]mddd[/eluser] I have had memory problems with scripts inserting large amounts of data into the database. I found that the problem was, that CI keeps record of all the queries it does. This is so that you can see them all when you turn on the Profiler. If you turn on this 'remembering of queries', you can save memory. The more queries you run, the more effect it will have. Turn it off using: Code: $this->db->save_queries = false; Also, it is a good idea to free up database results when they're no longer needed: Code: $query = $this->db->query('SELECT name FROM some_table'); Backup problem: "Fatal error: Allowed memory..." - El Forum - 06-01-2010 [eluser]TheoR74[/eluser] I added that save_queries line of code and that did make a HUGE difference! Thanks alot. Backup problem: "Fatal error: Allowed memory..." - El Forum - 06-01-2010 [eluser]mddd[/eluser] You are welcome. Some more tips that might help you: Try combining INSERT statements. For instance: Code: INSERT INTO table SET col1='value1', col2='value2' Code: INSERT INTO table (col1, col2) VALUES ('value1','value2'), ('value3', 'value4') If you are writing a LOT of information, it can often be quicker to write all the data to a file first, and then load the file with the LOAD DATA INFILE command. But this does require 'file' rights in Mysql. If you are on shared hosting you may not have those rights. Backup problem: "Fatal error: Allowed memory..." - El Forum - 06-01-2010 [eluser]Buso[/eluser] nice tips, thanks for sharing |