Entry
How much memory do I need to compile PHP?
Why do I get a "virtual memory exhausted" error in bison when compiling?
Jul 5th, 1999 15:39
Mathijs Brands, Nathan Wallace,
Compiling PHP requires a reasonable amount of memory.
Here is an example error message from a machine with only 8MB of RAM and
8MB of swap memory.
ha:/tmp/php-3.0.11# make
gcc -g -O2 -O2 -fpic -I. -I. -I/usr/local/apache/include
-I/tmp/include -c language-parser.tab.c -o language-parser.tab.o
/usr/lib/bison.simple: In function `phpparse':
/usr/lib/bison.simple:692: virtual memory exhausted
make: *** [language-parser.tab.o] Error 1
ha:/tmp/php-3.0.11#
If you are having memory problems when compiling you may like to try
installing pre-compiled PHP binaries.
--- Another suggestion -------------------------------------------------
If you are using linux, you might try something else.
Under Linux it's very easy to temporarily add some extra swapspace
using a swapfile. A swapfile is a bit slower than a swappartition,
but not much. The process described below is very similar to the
one used for swappartitions (the dd isn't needed), but a lot less
risky in case of a typo.
First you need to create the swapfile somewhere. Suppose we want
to create a 32 MB swapfile in /tmp:
dd if=/dev/zero of=/tmp/swapfile bs=1k count=32k
(do this as a normal user, that's much safer)
After creating the swapfile, you must use mkswap on it. If you
don't, Linux will refuse to use it as a swapfile.
mkswap /tmp/swapfile ; sync
(do this as a normal user)
Now the swapfile is ready to be used. Tell Linux to start using
it.
swapon /tmp/swapfile
(you must be root to do this)
If you use the free command, you should be able to see that the
amount of swapspace increased by almost 32 MB. (top should show
you the same.)
If you don't need the swapfile anymore, tell Linux to stop using
it and delete swapfile. Note that after a reboot Linux doesn't
automatically start using the swapfile.
swapoff /tmp/swapfile
(you must be root to do this)