homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

PHP 5 Memory Useage
high memory useage since php 5 upgrade

 6:22 pm on Jan 5, 2008 (gmt 0)

I finally got round to upgrading my live server to php5 on boxing day whilst it was quiet.

All is generally well but on a few large scripts i'm getting "Allowed memory size..." errors. Obviously i've upped the allowed memory size but a couple of scripts are still hitting the buffers which isn't good.

This was never happening in php4 so it's difficult to know what the problem is

any help would be most appreciated as always




 5:23 pm on Jan 6, 2008 (gmt 0)

Without seeing the script it is nearly impossible to tell. At the very least, we need to know what these scripts do.



 9:50 pm on Jan 6, 2008 (gmt 0)

they're standard loops on the whole, but generally large ones buffering data into memory and then outputting to smarty.

I know these are fairly heavy on memory, my issue is that i wasn't getting these errors prior to my php5 upgrade whereas i am now even with substantially more memory allocated per script.


select Col1, Col2 from table
while $row=mysql_fetch_array..


 2:48 am on Jan 9, 2008 (gmt 0)

I cannot see how a routine as simple as what you posted is going to change much between versions.

Either way, if you use mysql_fetch_assoc(), you could cut that memory usage down.



 7:59 pm on Jan 9, 2008 (gmt 0)

Check to see if you are doing includes() within loops. That is one practice that often sets the memory reeling.


 10:31 pm on Jan 9, 2008 (gmt 0)

Hi Coopster, nowt special i'm afraid, it's just a big export to csv, using mysql to pass to an array which passes to my CSV generator function.

around 1000 rows with around 20 fields per row.

it's the same script that didn't miss a beat on version 4 with 8mb per script, now it only manages when it's got 64mb of script memory.

I wonder if my server setup is the issue. I saw there were a number of memory leak issues in PHP 5.2 which were rectified, but this is 5.2.5 and aapprarently they've been fixed.


 3:02 am on Jan 10, 2008 (gmt 0)

Hey, I just installed PHP-5.2.5-r1 on my local Gentoo box and noticed this message. It reminded me of this thread.

* With PHP 5.2, some extensions were removed from PHP because
* they were unmaintained or moved to PECL. Our ebuilds reflect
* this: the Filepro and HwAPI (Hyperwave-API) extensions were
* removed altogether and have no available substitute.
* The Informix extension was also removed, as well as the optional
* memory-limit setting: memory-limit is now always enforced!


 8:18 am on Jan 10, 2008 (gmt 0)

interesting, so it might have been using the same amount of memory, just not kicking up a fuss about it.

Is there any way to see the exact script memory consumption in PHP4?


 5:32 pm on Jan 10, 2008 (gmt 0)

You can echo it to the browser at certain breakpoints in your script using memory_get_usage() [php.net] and flush() [php.net].

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved