Welcome to WebmasterWorld Guest from 54.162.12.134

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP 5 Memory Useage

high memory useage since php 5 upgrade

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

10+ Year Member



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

hughie

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

WebmasterWorld Senior Member 10+ Year Member



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

Marty

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

10+ Year Member



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.

example

select Col1, Col2 from table
while $row=mysql_fetch_array..
{
$array[$count]=$row;
$count+=1;
}

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

WebmasterWorld Senior Member 10+ Year Member



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.

Marty

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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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)

10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



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)

10+ Year Member



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)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

Featured Threads

Hot Threads This Week

Hot Threads This Month