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
The most common performance problem associated with Java™ relates to the garbage collection mechanism. If the size of the Java heap is too large, the heap must reside outside main memory. This causes increased paging activity, which affects Java performance.
There is no guarantee that the actual GC will be triggered. System. gc() triggers a major GC. Hence, there is a risk of spending some time on the stop-the-world phase, depending on your garbage collector implementation.
The consensus is that a programmer should never utilize this method. The JVM garbage collector and the G1 in particular, do a very good job determining when a garbage collection is needed. Furthermore, System. gc() can induce a full GC, and the method will also wait until the full GC is ready.
Garbage collection is the memory management process for objects in the heap. As objects are allocated to the heap, they run through a few collection phases – usually rather quickly as the majority of objects in the heap have short lifespans.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With