Forum Moderators: coopster

Message Too Old, No Replies

Fatal error: Allowed memory size of 8388608 bytes exhausted

I am getting this error, how to solve it

         

AjiNIMC

8:16 am on Oct 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 184320 bytes)

What can be the reason? How do I free memory in PHP. will flush() help?

TIA
AjiNIMC

jatar_k

2:29 pm on Oct 29, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can free up all vars that you aren't using.

are you parsing a ton of data or something?

ergophobe

3:57 pm on Oct 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




will flush() help?

Only if you have tons of output that has gotten buffered but not sent. It shouldn't hurt though.

More likely, as JK suggests, are you parsing large amounts of data and feeding it into arrays? Creating many instances of a larg array or object? Could you delete obsolete arrays?

coopster

3:37 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you using an include() function inside a loop? I've seen code like this before where the included file really should have been a function that was passed variables as opposed to being included every time.

AjiNIMC

4:11 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was able to solve the problem using using memory_get_usage() at different level. There was a pear package which was eating up all the resources.

Thanks for the help.

AjiNIMC

jatar_k

4:19 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> There was a pear package which was eating up all the resources

astonishing ;)

AjiNIMC

5:19 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yeah very strange but somehow true but I need to investigate more.

I was using

pear.php.net/package/Spreadsheet_Excel_Writer , I just included the file.

AjiNIMC

coopster

5:30 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



jk was being sarcastic, he's not much of a PEAR fan. Must have had a bad experience once ;-)

But in all fairness, that package is not maintained. You would have to really scrutinize the code to ensure it behaves as you expect. One thing that is odd is that the total package size is 287,548 bytes -- a far cry from the numbers you posted as the memory allocation issue.

AjiNIMC

6:09 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



there were few more packages which were eating up the resources, this package was the main culprit but.

I will have to optimize it better.