Installing the latest versions of v8 and v8js on Ubuntu
Committing semi space failed. Allocation failed - process out of memory
PHP Fatal error: Evacuation Allocation failed - process out of memory
V8Js::__construct(): Failed to create V8 context
It may seem like a simple resolution would be to simply increase the memory resources available on the server. I did in fact do this, and it did not reduce the occurrence of the issues. I thus felt it worthwhile to investigate other resolutions, namely making sure that I was utilising the most up to date version of v8 and v8js respectively.
To my surprise it turns out that the version of v8 available within Ubuntu's package manager (at the time of writing) is 3.14.15. Given that the current version is 5.1.0 it is apparent that this version is seriously outdated.
To update v8 we are therefore going to have to manually build the latest version. This is a little more complex than using a one line package manager, but is unfortunately a necessary evil.
One obvious benefit is that by compiling yourself you put yourself in control of the specific library versions that you are using. You can compile specific versions consistently across platforms. There is no need to introduce errors or inconsistencies as a result of having one version of v8 on your Mac (through MacPorts) and another on your server (through aptitude).
I encountered a few issues in the process, and as such I thought I would outline them for anyone having troubles.
Using depot_tools to pull in the v8 source is in and of itself memory intensive. I had issues which were resolved simply by increasing the memory available.
The build steps are likewise memory intensive.
When building v8 I got a number of errors pertaining to ICU. Now I was (and still am) blissfully ignorant (my bad) of how 'building' works behind the scenes and what exactly 'ICU' is. That said installing the ICU library using the following command resolved my issues:
sudo apt-get install libicu-dev.
Once you have compiled v8, you need to install the appropriate version of v8js.
Whilst you can utilise PECL to do this on Ubuntu, you may as well compile it yourself such that (once again) you can have fine grained control over the version that you are using.
The only issue I encountered regarding compiling v8js is that there are now different versions of the library depending on if you are running PHP 5.x or PHP 7. You need to make sure that you clone the master branch if using PHP 5.x.
As of now this has resolved my issues entirely ! We have had no memory issues within our error logs.
That said, it has only been half an hour since I updated to version 5.1.0 (v8) and 0.6.0 (v8js) respectively :)