7 thoughts on “The Ruby Memory-Leak Problem

  1. I don’t know of any memory leaks in ruby 1.8.6.

    Just claiming there are leaks and pointing to my memory profiler isn’t exactly a fair claim. Can you show _where_ there are leaks? Are you certain they are leaks? I find a lot of people don’t really understand ruby memory management.

    If there is some way in which I can help, please let me know.

  2. Thank you for your reply!

    Well basically it is as following: Our Application at http://www.oddb.org grows over one day so much in memory that at a certain point of memory usage the Garbage Collection takes a very long time (too long time) to run (something like 50 secs or more). Our Application is then around 2 GB big in the RAM. After that we do a restart of our Application and like this just over and over again. We are happy to have any suggestions, our Software is OpenSource and can be found here: http://scm.ywesee.com – The memory usage snapshot of our Application can be found here: http://ch.oddb.org/resources/downloads/status

  3. I had a similar problem once. By printing out the resident size before and after each request I was able to narrow it down to one specific area of bad code. I’m not sure how to add those kinds of metrics to your app, though.

  4. As I said in my blog. I know of no memory leaks in ruby 1.8.6 itself. Bad code can of course “leak”. With pure ruby what we mean by leak is “objects holding onto other objects”. As long as an object is reachable, it is live. If it is live, it takes up memory. That’s totally valid and not a leak in the C sense of the word, where you’ve let go of memory without deallocating it. What I’m basically saying is, if you’re running pure ruby, the leak is almost positively in your code (or a misunderstanding of “leak”).

    I briefly looked at your code. It is in a style and structure I’m not familiar with and would have to put some real time into studying to try to find any leaks. I don’t have the extra time right now to do that for free unfortunately.

  5. 1. Thank you Eric for your Feedback. I will discuss that with Hannes and get back to you via this blog.

    2. Ryan, thank you for your Feedback. I still believe that the memory leak is in Ruby 1.8.6 as the GC takes longer and longer to run, the bigger our App gets. Obviously in our application not all the threads get cleaned out by the GC that should get cleaned out.

    3. Any hints to memory management / memory measurement tools are highly welcome and will be posted on this site.

    4. Also hints to posts where memory and Ruby are discussed are very welcome.

    5. I really want to improve on this obstacle as it has been chasing us for too long.

  6. I have the same problem now:
    use “RDoc” at ruby’s install path,
    memory usage is increasing rapidly, from 100+M to 200+M, … to 800+M!

    In fact, RDoc does it’s job by calling ruby.exe, so i believe in that Ruby1.8.6 has “Memory-Leak Problem”.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s