PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 13th, 2000, 04:11 PM
sladeeee sladeeee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 2 sladeeee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Everyone

I've been using PHP for a few weeks and was going along quite nicely until I started to stress my application a little more than before and had the following error half-way through a page display:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 12288 bytes) in calcprofile.inc on line 144

I'm not particularly bothered about the code line in question (in fact it's just a debug message) but I'm interested in understanding what is happening with the PHP memory management. While my code is pretty intensive in terms of number of calculations per page request, I can't believe I'm using over 8M of memory per page request - doesn't PHP automatically clean up variable memory after each page request?

The alternative is that I really am using that much memory (eeek), in which case is there anyway I can improve the memory management myself? I use mysql_free_result() as soon as I finish with a request but nothing else explicit. Maybe functions should be used rather than includes() whenever possible? This is all a nasty surprise for a C++ programmer who is used to cleaning up nicely behind themselves :-)

Any feedback or ideas would be really appreciated...thanks.

Oh, I'm running PHP3 under Apache on Linux.


-Mark.
zigzagzoo.com

Reply With Quote
  #2  
Old March 13th, 2000, 04:48 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 17
Send a message via AIM to rod k
Yes, php cleans up after itself, so it is your script that is using that much memory. If you're freeing your SQL results there isn't much else I can say without looking at your code (and I don't think I want to do that!). You can increase the available memory by changing the memory_limit directive in the php3.ini file.

good luck

Reply With Quote
  #3  
Old March 15th, 2000, 04:56 PM
sladeeee sladeeee is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 2 sladeeee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
In the end I moved some code that was simply "include()"d and made it into a function - this seems to have dramatically reduced the memory usage and my problems have gone!

So the moral of the story is write your code properly in the first place and don't nest includes!


-Mark.
zigzagzoo.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP Memory Errors

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap