Any performance disadvantages of GC.disable?

476 Views Asked by At

Are there any circumstances where GC.disable can degrade performance? Is it ok to do, so long as I'm using real RAM rather than swap memory?

I'm using MRI Ruby 2.0, and as far as I can tell, it's 64 bit, and using a 64 bit Ubuntu:

ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]

Linux [redacted] 3.2.0-43-generic #68-Ubuntu SMP Wed May 15 03:33:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
1

There are 1 best solutions below

0
On

GC.disable will disable garbage collection. Languages like ruby have no way to free up memory without garbage collection because unlike C you don't invoke a memory deallocator manually.

So yes, there will be a performance hit. Eventually you will run out of memory as objects like strings will keep getting created and never cleaned up. You may not even be responsible as internal mechanics of APIs you use may generate objects.

Without a better understanding of the problem this is unfortunately the best I can offer.