Any performance disadvantages of GC.disable?
Asked Answered
E

1

6

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
Egghead answered 19/6, 2013 at 2:20 Comment(1)
guess it depends on your application, you should do performance tests and memory profiling with and without enabled gc to get some basis to ground your decision onAutoerotic
E
1

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.

Empennage answered 8/7, 2013 at 10:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.