tags:

views:

54

answers:

3

Does PHP have a built-in limitation on how much memory it can use? In other words, if I have a machine with many gigs of RAM and change php.ini to allocate most of them, will scripts still hit some lower limit?

(If you're curious, the goal is to run an automatic documentation generator, written in PHP, on a very large PHP code base.)

+1  A: 

PHP will consume as much as it has, this depends on your operating system. You can not extend the memory limit of PHP beyond what your OS has to offer.

Sarfraz
If I understand correctly, a 64-bit OS can handle more memory than a 32-bit one, right? So if I have a 64-bit OS, PHP would be able to use as much as the OS can give it - PHP itself isn't 32-bit?
Nathan Long
Only if PHP was compiled as a 64bit binary, otherwise it'll be limited to around 3 to 3.5gig, which is the most any 32bit app will ever see, as the OS and hardware require some breathing room for memmapping. Even the 64bit versions are limited as the processor may be 64bit internally, but has somewhat fewer bits available on the address bus. eg. athlon 64 only has 48bit hardware addressing, giving a 256TB limit. Still huge, but definitely not the full 64bit (16EB)
Marc B
+1  A: 

Apart from the PHP ini directive memory_limit you are only bound by the machine's available RAM. Note that memory_limit is per script, so running multiple scripts at the same time can eventuall sum to more memory than you server has.

Gordon
+1  A: 

The maximum amount of memory per process can also be limited by the operating system and/or some configurable resource limits.

E.g. on a windows system a 32bit process is limited to 2/3/4 GB memory per process (depending on whether you use a 64bit version of windows and the setting of IMAGE_FILE_LARGE_ADDRESS_AWARE). A 64bit process might be limited to 2GB as well (with IMAGE_FILE_LARGE_ADDRESS_AWARE cleared).
On a linux system there are similar restrictions and often limits set via ulimit.

VolkerK