Question

When I try to compile Phalcon, I get an error:

virtual memory exhausted: Cannot allocate memory

I am running the following commands

git clone --depth=1 git://github.com/phalcon/cphalcon.git 
cd cphalcon/build 
sudo ./install

I have a VPS with 1GB RAM

Was it helpful?

Solution 2

It seems GCC is allocating a lot of memory, check this

https://web.archive.org/web/20141202015428/http://hostingfu.com/article/compiling-with-gcc-on-low-memory-vps

Stopping as many services as possible (Apache, MySQL etc.) will free up more memory, and Phalcon will compile. Worst case scenario you will need to increase the memory of your virtual box.

Thanks to @AndrewD for providing the link that works.

OTHER TIPS

Add more swapfile may help. I met this problem when tried to compile YouCompleteMe for vim, solved it by adding swapfile.

https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-14-04

Another option that Andres suggested is to build from a different folder:

https://forum.phalconphp.com/discussion/7891/upgrading-from-201-to-205-getting-virtual-memory-exhausted-canno

The steps would be...

git clone --depth=1 git://github.com/phalcon/cphalcon.git
cd cphalcon/ext
sudo ./install

As he explained it, this approach uses less memory but takes more time and for newer version of GCC >4.7 the end result is the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top