Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Garbage Collection every 100 seconds

Did any one encountered a scenario where application under high memory allocation load performed second generation collection every 100 seconds ?

We using 64-bit server with 8-16 GB of physical memory.

Application has several GB of data what is stored in cache and can't be cleaned from it because it's actually used by application. In addition it receives a lot of request that allocate GEN 0 object during processing.

What it's odd to me is the fact what GEN 2 collection performed evey 100 seconds like a clock. I was thinking it shuld be less predictable

like image 731
MichaelT Avatar asked Feb 26 '09 13:02

MichaelT


People also ask

How do I fix long garbage collection time?

High Object Creation Rate A high garbage collection rate will increase the GC pause time as well. Thus, optimizing the application to create fewer objects is THE EFFECTIVE strategy to reduce long GC pauses. This might be a time-consuming exercise, but it is 100% worth doing.

What is garbage collection time?

The more live objects are found, the longer the suspension, which has a direct impact on response time and throughput. This fundamental tenet of garbage collection and the resulting effect on application execution is called the garbage-collection pause or GC pause time.

What is the acceptable number for percentage of time spent in garbage collection?

The percentage of time in garbage collection should be less than 3% - This percentage can be calculated by dividing the sum of the garbage collection times over an interval by the interval.

How can I speed up my garbage collection?

Short of avoiding garbage collection altogether, there is only one way to make garbage collection faster: ensure that as few objects as possible are reachable during the garbage collection. The fewer objects that are alive, the less there is to be marked.


2 Answers

If you are under high memory load, and using a lot of objects, then yes: GC will get busy... if it is hitting gen-2, then it sounds like you've got a lot of mid/long-life objects hanging around...

I'm assuming that memory usage is fairly stable? The above could indicate some kind of pseudo-leak (perhaps holding onto too many objects via static events, etc), or could just mean that you have a high memory usage!

How much memory are you using? Could you consider x64 and a ton of memory? Alternatively, would the 3gb switch (x86) buy you a few more bytes?

like image 168
Marc Gravell Avatar answered Oct 10 '22 17:10

Marc Gravell


If you are running a dual core CPU, try setting GCServer="true" in the app/web.config.

In my case, it does about 10% of the original GC's and the application feels a lot snappier.

like image 30
leppie Avatar answered Oct 10 '22 18:10

leppie