The allowed memory size of 67108864 bytes has been exhausted (tried to allocate 4459414 bytes) when writing an xml file

Possible duplicate:
Allowed memory size 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php

I saw similar problems here, but mine is completely different. I am reading from a database and writing to an XML file. I get this error

<b>Fatal error</b>: Allowed memory size of 67108864 bytes exhausted (tried to allocate 4459414 bytes) in <b>.../public/home/..</b> on line <b>32</b><br />. 

What should be the solution? Increase memory in code? Any help?

+4
source share
2 answers

Do mysql_unbuffered_query() , not mysql_query() . Probably your request returns too much data, as for your php server.

+3
source

Try increasing or removing memory_limit in php.ini .

Find something like this and change the value of memory_limit

 ; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit memory_limit = 128M 

(this is part of my php.ini)

Reboot the server after saving the changes.

Alternatively, you can try to remove the restriction from the code.

Example:

 ini_set('memory_limit', '-1'); 

This should work fine.

Another way is to set the memory limit from the .htaccess file by adding the line:

php_value memory_limit 128M

(128M is just an example)

Note. For shared hosting, I doubt very much that you can change the memory limit.

+13
source

All Articles