We have application that runs 24h per day and 7 days per week. Sometimes CPU go to 100% and then go back to 80%. The same with RAM. Is it smart to manually call GC.Collect
after few hours or betterto leave it automatically.
We are using C# 2010, SQL 2008 and Fluent Nhiberanet. This is desktop application.
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. Also, a large heap can take several seconds to fill up.
Refrain from calling the GC. Collect method explicitly to reclaim the memory occupied by the objects in your application unless there is a specific reason do so. The GC. Collect() method has for long been popular among .
One fundamental problem with garbage collection, though, is that it is difficult to estimate and manage the actual size of the working set in memory, because garbage collector can free your memory only delayedly. So, yes, when memory is restricted, garbage collection might not be a good choice.
The GC. Collect() is a very expensive method which should be avoided.
I wouldn't call it smart to call GC.Collect()
"every few hours", or "when RAM usage goes to high", but I'd call it smart to call it whenever you are in a position of having more information than the GC, some exmaples
The GC is a highly optimized peace of code and quite smart, but it can only work on information it has.
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