ok so I'm really confused about how Apache, PHP and WordPress memory allocation works.

For example in WordPress there is a config variable (define('WP_MEMORY_LIMIT', '64M');) for memory allocation which is typically set to 64M by default.

In addition PHP has a memory allocation in php.ini (memory_limit) which is set really low by default (e.g. 128M)

If I have a server with 2GB of ram how should I allocate memory to WordPress and PHP?

e.g.

Should I set php memory to 2GB? The server is a VPS also running mysql, cpanel etc. so I'm thinking I should probably limit it to 1GB instead. Also, if I limit php memory to 512MB will it ever use more than 512M anyway?

Then, what about WordPress - should I set it to match the php limit?

If I have php set to 1GB of memory and 2 WordPress sites should I set each to 512MB - will WordPress obey the memory limit aswell?

Just trying to get a handle on my memory allocation strategy.

Many thanks!

Ed

link|improve this question

33% accept rate
feedback

1 Answer

up vote 2 down vote accepted

Ouch. The limit is per thread and should definitely not set to a too high value, cause than one single script could knock out your machine. 64MB should be fine for must PHP applications, otherwise they should be rewritten ;)

link|improve this answer
ahhh - i forgot about threads :) of course! – Ed Bloom Apr 11 '11 at 19:24
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.