Forum Moderators: coopster

Message Too Old, No Replies

writing a large xml file with fwrite getting error

         

asamm

3:29 pm on Jul 6, 2007 (gmt 0)

10+ Year Member



Hi

I have about 8000 products to export. I have written an script to write products to an xml file using the fwrite() function of php , but when I try this it gives the following error

Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 204 bytes)

I am on shared server and asked the webhost to increase the memory, but i am not sure if that works.

I would appreciate any advice and help

thanks

JAB Creations

4:01 pm on Jul 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not a PHP genius but from what I have read you may have an infinite loop somewhere that just continuously adds stuff to the memory. I'd comment out whatever loops you may have, restart Apache, and see if the problem persists. Hope this helps! ;)

- John

*Edited for typo, ops!

[edited by: JAB_Creations at 4:01 pm (utc) on July 6, 2007]

asamm

5:41 pm on Jul 7, 2007 (gmt 0)

10+ Year Member



Hi John

thanks for your reply, I have checked and there is no indefinite loop. I can export up to 2500 products but when I increase it I get this message.

Any more idea

asamm

9:05 am on Jul 10, 2007 (gmt 0)

10+ Year Member



any ideas guys

thanks

joelgreen

9:29 am on Jul 10, 2007 (gmt 0)

10+ Year Member



There is a setting in php.ini to limit allowed memory. I believe it is causing problem and needs to be increased.

Like this

memory_limit = 2M ; Maximum amount of memory a script may consume (8MB)

How do you load those 8000 products? All at once into some array and than export all, or you read/save them one by one?

asamm

7:46 pm on Jul 10, 2007 (gmt 0)

10+ Year Member




I am on a shared server, and they refused to increase the memory size. I have tested different version of the script all are working on the local server, but not on the live. I tried to save all of them on one array than save on xml file. I also tried to save 1000 products at a time.

OK now I am going to change the script to use header('Content-Disposition: attachment;... to force a download.

I will let you know how this goes.