Web developer & teacher @saaslit
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.