Home > Net >  Where is the meaning of.net on GC recycling?
Where is the meaning of.net on GC recycling?

Time:01-07

Believes that many people have talked to a job interview GC, recycling of GC are some related articles, such as:
When the GC
1, when the application is assigned a new object, the size of the generation of budget GC has reached a threshold, such as GC of generation 0 is full;
2, active code explicitly call System. GC. Collect ();
3, and other special circumstances, for example, Windows reports out of memory, the CLR unload AppDomain, CLR closed, and even some extreme cases system parameter change can also lead to GC recycling,

Translation, this statement comes from the Microsoft related articles on the threshold of 1 case, explain very general very abstract, did not give a specific value, how to configure, and so on, for example, I wrote a program run how to know when I reached the threshold to trigger the recycling,

So the question comes, the.net is based on the language of the host, the GC recycling trigger is very fuzzy and uncertain, pay attention to the significance of GC in where?
Whether the unmanaged resources (files, database connection, etc.) it is enough to release?

CodePudding user response:

.net little attention, but if with unmanaged code development have to think about. This is very annoying, all kinds of nausea

CodePudding user response:

reference 1st floor ziqi0716 response:
.net little attention, but if with unmanaged code development have to think about. This is very annoying, various nausea

Unmanaged code does not belong to GC's worlds, it don't want to pipe and pipe

CodePudding user response:

Just like you acting the role of vehicle traveling data recorder, although he almost nothing, but really, you know he useful for

And the garden is different, the real development is no matter, also is the back garden like NB and feel will gc can give HR and test tubes to kan dizzy
In fact the truth is, if I know the door wide enough (memory), then you can do only two things
1. Line up, don't jump the queue, don't compete for
2. Everyone gave me fast in the past, don't block the door, (large task to I hurt small, smooth can quickly in the past, every day thinking about how to build a more strong than you door useful)

So, you see our discussion of GC, those who say a NB blowing a GC how killings, in fact, the reason is very simple, they just want to how to make strong the door, the result is in strong door, you also can't mad dash with someone is not in the past, he blocked the door, ok, the killings took place, so, continue to seek a more solid door

CodePudding user response:


The problem about the threshold, the threshold of upper and lower threshold and threshold coefficient of up and down the line

With the threshold limit of 0, 0 online for about 6 MB
Threshold limit of the first generation of 160 KB, ceiling unlimited
The second generation of the threshold limit of 256 KB, ceiling unlimited
The second generation of large object threshold limit is 3 MB, launch unlimited

As for the factor, due to distinguish between the server and work mode 0 generation so respectively (9, 10 and 20, 20) the rest of the generation of
Upper and lower and 12 size object respectively (2, 7-1.2 f, 1.8-1.25 f, f 4.5 f)

Because every trigger a GC recycling new allocation amount calculation, allocation amount is calculated according to the coefficient and the last time allocation amount, the top value is less than the above number, more than the disadvantages will trigger the physical memory, also associated with GC again,
The specific calculation method is as follows:

Float allocation_fraction=(float) (dd_desired_allocation (dd) - dd_gc_new_allocation (dd))/(float) (dd_desired_allocation (dd));//calculation deviation rate
CST=min (1.0 f, float (out)/float (dd_begin_data_size (dd)));//survival rate calculation, the GC after the live object size/prior to the start of the generation live object size
F=surv_to_growth (CST, limit, max_limit);//calculation threshold value growth factor
If ((allocation_fraction & lt; 0.95) & amp; & (allocation_fraction & gt; 0.0))//when migration rate greater than zero is less than 0.95
{
//=new allocation amount threshold migration rate * new distribution of the threshold value + (1.0 -) migration rate * is assigned the threshold
New_allocation=(size_t) (allocation_fraction + (1.0 - allocation_fraction) * * new_allocation previous_desired_allocation);
}

CodePudding user response:

Don't need too entangled with automatic garbage recycling this thing ~ c # automatic garbage recycling popular point: in one place you throw rubbish, don't need you to pick it up and threw it into trash can, because someone will regularly to clean, and a language such as c + +, they throw the rubbish (new) must quickly picked it up and throw it away (delete), is such a difference, to unmanaged resources such as file streams, such as database connection operation, only need to use the using enclosed,
  •  Tags:  
  • C #
  • Related