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

Im getting the following while creating a big string.

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4034460 bytes) in /home/httpd/vhosts/website.com/httpdocs/feeds/feed.php on line 349

Any ideas on how to correct this?
cimmerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

snoyes_jwCommented:
Try setting memory_limit higher in php.ini
Diablo84Commented:
heres my reply in the other question:

 yes by default the maximum allowed memory for a script is 8mb which is the equilivant to 8388608 bytes

for some reason your script is using up more then 8mb of memory

either theres a bug in your script or the output is very large

you need to increase the value in the ini setting

if you have access to your php.ini file incrase the value in this line

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

if not you should be able to change it using the ini_set function (look it up in the manual @ php.net)

Diablo

      
      
Diablo84Commented:
here try putting this at the top of your script

ini_set("memory_limit","20M");

thats for 20mb, increase it more if needed

Diablo

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

cimmerAuthor Commented:
Are there any dangers to setting that too high?
Diablo84Commented:
if your system has enough memory to support it and other processes then no

if its an actively running script they you might want to look into reducing the amount of resources it requires however if it is only go to be run every so often i wouldnt see it as a big issue
cimmerAuthor Commented:
it will only be run once a month or so
Diablo84Commented:
not a problem then in my opinion

the only real risk is if there were lots of users running the script simulataneously then your systems resources would be eaten up very quick but as this is not the case your system should have no trouble coping with it.
Random_PeteCommented:
If your script uses that much memory it might take longer than 30secs to run ... add this line

ini_set("max_execution_time","3600");

Otherwise your script will bomb out after 30 seconds!

http://www.downplay.co.uk
PHP Development, Web & Database Design
Diablo84Commented:
Random_Pete it is a serious violation of the EE rules to use your business name as a signature
http://www.experts-exchange.com/Community_Support/help.jsp#hi106
Random_PeteCommented:
I apologise, I wasn't aware. Is there a way I can remove it from my posts?
Diablo84Commented:
quite alright i was just letting you know so you don't get in trouble with mods in the future.

You can't remove it yourself, you could post a request in community support to get them removed from your comments, im not sure how strict the mods are on enforcing the policy but you may well be ok to just leave them and not include the tag in future posts.

Thanks, Diablo
Random_PeteCommented:
Ok, thanks for the warning ...
hlslaughterCommented:
It's not necessarily the script using too much memory. It could have to do with a known problem (memory leak) in php 4.2. I see this same error when running PEAR, And I'm assumming PEAR is not trying to use more than 10M of memory. You'd have to have a pretty horrific piece of code to use up 10M in a single script (except when handling large binary files maybe :)

The rumored fix is an upgrade to 5 *or* increasing your memory until you don't see that error anymore. But I tried to install a PHP app that would not work even when I set the limit to 300M!! So I'm going to upgrade to 5.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.