Configure MRI Ruby GC to fail fast

58 views Asked by At

I'm working on a Ruby on Rails application which has a memory leak, so eventually it crashes when there's no more memory. However, in the final stage it basically only running the GC and processing very few requests, so basically DoS-ing itself. This DoS time was between 1 hour and 6 hours for my application!

I tried to locate the memory leak but no luck so far, so now I want to find a workaround for the production server.

Is there a way to configure the MRI Ruby GC so that when it reaches the memory limit then it just crashes? I mean to crash at the first time when Ruby tries to allocate more memory and the operating system denies it.

1

There are 1 answers

0
unkmas On

As far as I know, you cannot do that.

But your have another options:

  1. Setup something in your system, which will prevent ruby from using too much memory (oom maybe?)
  2. Setup your webserver to kill itself - like in this gem