2

In my rails application total object are increasing with every request. Objects are not freeing after GC runs. I am using Rails 3.2.3 and ruby 1.9.3.

Can someone point me in right direction ? Where to start?

What are the available tools ?

Tools which I tried. ObjectSpace is not referencing a line where these objects created. Memprof is not working with ruby 1.9.3. Oink is not referencing a line where these objects created.

krunal shah
  • 16,089
  • 25
  • 97
  • 143
  • 3
    Ruby, like any good GC, wants to minimize the dynamic memory allocations and deallocations. That means that Ruby will allocate a lot of memory once, and keep that memory around for new objects so that there doesn't have to be as many context switches or dynamic allocations. Ruby will only release memory when memory is tight. – Linuxios Jul 06 '12 at 13:49
  • 1
    Maybe this comment should be an answer? – robbrit Jul 06 '12 at 14:48
  • @krunalshah How do you know that GC ran the corresponding resquest/response cycle perhap GC only runs if the memory reach above a threshold unless you manuall invoke `GC` using `GC.start` in your code which too bad – Viren Jul 09 '12 at 03:12

1 Answers1

0

perftools.rb has the ability to mention what methods create how many objects:

CPUPROFILE_OBJECTS=1

Profile object allocations instead of cpu/wall time. Each sample represents one object created inside that function.

However, that's profiling all objects, not merely un-garbage-collected objects. Also, it segfaults on me some of the time.

Community
  • 1
  • 1
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338