Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any performance disadvantages of GC.disable?

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
like image 407
Andrew Grimm Avatar asked Jun 19 '13 02:06

Andrew Grimm


People also ask

Does garbage collection affect performance?

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.

Why system GC is not recommended?

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.

Is it good to use system GC?

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.

What is GC in performance testing?

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.


1 Answers

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.

like image 142
Dmitriy Likhten Avatar answered Sep 27 '22 21:09

Dmitriy Likhten