Idea to export large xml file with cakephp

I have to generate an XML file and then send it to the browser to be downloaded

I use XML class utility that comes with Cakephp 2.9.5

The problem is that when i have a large amount of data (>1000 record) that i get from the database, my script crushs cause of a memory leak.

Do you have any suggestions to avoid this problem ?

Thank you

Have you already determined what is consuming all the memory? One idea is to generate the file by writing to an external file instead of doing “echo”, as it will not consume memory in php, have you tried doing that?