Rails Assets Pipeline "Cannot Allocate Memory - Nodejs"

rails assets pipeline Cannot allocate memory - nodejs

It's simple to spend the three minutes (maybe two if you type fast) to add a swap file to your server.

If you're running Ubuntu (not sure how well this works for other Linux flavors), just follow this tutorial from DigitalOcean:

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

Voila!

Elastic beanstalk[Rails] deploy issue - Cannot allocate memory

The issue has been resolved by removing a large amount of assets that were not needed or used, for instance i had the entire bootstrap project source and a few 3rd party library project source tree's and corresponding files, instead of just the src files that i was using.

Getting error Cannot allocate memory for Rails

Both IO.popen and Kernel#system can be expensive operations in terms of memory because they both rely on fork(2). Fork(2) is a Unix system call which creates a child process that clones the parent's memory and resources. That means, if your parent process uses 500mb of memory, then your child would also use 500mb of memory. Each time you do Kernel#system or IO.popen you increase your application's memory usage by the amount of memory it takes to run your Rails app.

If your development machine has more RAM than your production server or if your production server produces a lot more output, there are two things you could do:

  1. Increase memory for your production server.
  2. Do some memory management using something like Resque.

You can use Resque to queue those operations as jobs. Resque will then spawn "workers"/child processes to get a job from the queue, work on it and then exit. Resque still forks, but the important thing is that the worker exits after working on the task so that frees up memory. There'll be a spike in memory every time a worker does a job, but it will go back to the baseline memory of your app every after it.

You might have to do both options above and look for other ways to minimize the memory-usage of your app.



Related Topics



Leave a reply



Submit