This bug is really tricky, so here is my journey solving it. Maybe this will help other not to be too impatient :)

· Ruby  · 2 min read

Get rid of Rails Failed to allocate memory

This bug is really tricky, so here is my journey solving it. Maybe this will help other not to be too impatient :)

Failed to allocate memory (No MemoryError)

I had this problem quite randomly, when I was booting a new Rails 7 application from a template.

Despite removing / recreating the project from scratch, I still go this error from Bootsnap

bootsnap - Failed to allocate memory (No MemoryError)

How to reproduce this error

You can’t. There is a opened issue on GitHub about this.

Don’t do things like I did

Don’t be impatient like me. Here is what I did :

  • Reboot my machine (didn’t solve the problem)
  • Upgrade the OS (didn’t solve the problem, but at least my OS was up-to-date)
  • Reinstalled rbenv (still had the bug)

What I should have done

I should have checked earlier that the problem was specific to the project. I mistakenly thought it was not the case after reinitializing everything.

Error doesn’t come from what we don’t know. It often comes from what we mistakenly admitted as true.

I should have tried to reproduce the bug on another unlinked project.

I should have read one more time how to get un-stuck

Solution to (No MemoryError) error

I ended up by removing the tmp folder of the project, which worked. Now this bug may still occurs from time to time, but I know how to correct it.

I plan now to remove bootsnap from my default template. 😬

Summary

It was that weird bug that you don’t want to encounter, and that makes this job sometimes difficult - but how enjoyable once corrected.

Share:
Back to Blog

Related Posts

View All Posts »
The simplest turbo-frame example

The simplest turbo-frame example

Turbo frame is a powerful feature of Hotwire, here is a quick memo about how to follow conventions in the simplest case. Convention over configuration is powerful, but sometimes it is also a problem when you are not sure anymore about conventions ;) so I plan to release more "simplest *** Hotwire feature".

My honest opinion about Hatchbox

My honest opinion about Hatchbox

Hatchbox.io is a deployment platform for Ruby-on-Rails users. I used it recently, so for people ashamed of trying, here is my review.