Too much memory usage on blank page?


I recently upgraded the PHP version of one of my sites to 5.3.0 in the Dreamhost control panel. Over the past few days, I’ve noticed the memory usage on my site seemed a bit high as well, so I decided to try troubleshooting it.

I created a blank test page and reduced it’s entire code down to:
echo memory_get_peak_usage()."

This is what my memory usage is on the page:

This is over 620KB being used on a totally blank page. It seems a bit much, especially if traffic were to ever pick up dramatically. I print these numbers out on all my pages when my admin account is logged in and my LIVE homepage used to only use between 200k and 400k memory. That number is now 800k-900k and the rest of my pages are using much more memory now, which is my major reason for concern.

Let me know if this seems normal to you, or if this is normal for PHP 5.3.0. Note, I’ve created PHPRC file to allow member to upload larger files and increase the timeout time. The file only consists of:
upload_max_filesize = 32M
post_max_size = 32M
max_execution_time = 300
max_input_time = 300

I’m not sure if this has anything to do with 620KB being used by default all pages.

Kind regards

Your phprc is fine and won’t be affecting the results. 620k sounds about right for DH’s implementation of PHP53. It’s a fully loaded environment with more bells & whistles than Santa. You’re right that the footprint increase from 5.2 -> 5.3 is seemingly a huge jump. The big plus for 5.3 is that it has far better memory management than it’s predecessor, especially with respect to garbage collection, so while the initial footprint might seem high it should remain very stable over time.

If the initial resource usage is of a major concern (and you’re writing your own stuff) you could probably reduce the mem req a bit by compiling your own PHP and only including things that your domain needs.

As an example, the config below uses under 370k on init with v5.3.18 (Centos with XCache, ionCube & Zend Guard loaders, no Suhosin)

Thanks for the reply, I had no idea if this was natural or not, seems like it is.

The configuration that you wrote above, is that something that gets copied and pasted into the phprc file?

Kind regards

I wish! But no, they are some PHP configuration options I used when building PHP on a Centos server.

It would be cool if we could disable parts of the core via an .ini edit, but PHP is a bit of a brick once compiled.

Our build of PHP 5.3 is largely modular. There are quite a few extensions loaded by default, but you can cut that back, if needed, by creating your own PHP.ini — see the directions at (You can’t disable extensions in phprc, so you’ll need to create a php.ini instead.)

Wait! What? How much can we actually strip away from the loading environment here?

I’ve not ever bothered to try… but if we can control mem requirements via .ini’s alone then I’ll knock up an interface.

Granted a couple hundred k mem is just pennies on the dollar considering DH’s box specs, but some users like to tweak about a bit to be nice neighbours.

Spoiler: Not very much, unless you want to start dropping critical features like MySQL and sessions. :slight_smile: I already did some experimentation with dropping extensions before the PHP 5.3 launch, and determined that the memory hit from the extensions we load is relatively minimal (and the biggest memory users are the extensions that users could least do without).

Yeah, “30% saving” looks good on paper, but when that “30%” is really just 200k on a 32,959,040k box it kinda loses it’s marketing punch :smiley: