f reachable queue in c#
C#
Freachable Queue
Freachable what? You might ask. Freachable (pronounced F-reachable) is one of CLR Garbage Collector
internal structures that is used in a finalization part of garbage collection.
You might have heard about the Finalization queue where every object that
needs finalization lands initially. This is determined based on whether
he has a Finalize method, or it’s object type contains a Finalize method
definition to speak more precisely. This seems like a good idea,
GC wants to keep track of all objects that he needs to call Finalize on,
so that when he collects he can find them easily.
Why would he need another collection then? Well apparently what GC does
when he finds a garbage object that is on Finalizable queue, is a bit more
complicated than you might expect. GC doesn’t call the Finalize method
directly, instead removes object reference from Finalizable
queue and puts it on a (wait for it.. ) Freachable queue.
Weird, huh? Well it turns out there is a specialized CLR thread that
is only responsible for monitoring the Freachable queue and when GC adds
new items there, he kicks in, takes objects one by one and calls
it’s Finalize method. One important point about it is that you shouldn’t
rely on Finalize method being called by the same thread as rest of you app,
don’t count on Thread Local Storage etc. But what interest me more is why?
Well the article doesn’t give an answer to that, but there are two things that come to my mind. First is performance, you obviously want the garbage collection to be as fast as possible and a great deal of work was put into making it so. It seems only natural to keep side tasks like finalization handled by a background thread, so that main one can be as fast a possible. Second, but not less important is that Finalize is after all a client code from the GC perspective, CLR can’t really trust your dear reader implementation. Maybe your Finalize will throw exception or will go into infinite loop? It’s not something you want to be a part of GC process, it’s much less dangerous if it can only affect a background thread.
Also in C#:
- Title
- unity resources load
- Category
- C#
- Title
- c# web form compare dates
- Category
- C#
- Title
- c# char array to string
- Category
- C#
- Title
- asp net identity include phone number when registering
- Category
- C#
- Title
- c# round number down
- Category
- C#
- Title
- variables
- Category
- C#
- Title
- get random number c#
- Category
- C#
- Title
- unity t-flip flop
- Category
- C#
- Title
- unity rotation
- Category
- C#
- Title
- unity how to change text in script
- Category
- C#
- Title
- set int to null c#
- Category
- C#
- Title
- c# timespan
- Category
- C#
- Title
- unity instantiate
- Category
- C#
- Title
- ecs get specific entities with component
- Category
- C#
- Title
- c# convert byte to char
- Category
- C#
- Title
- c# webrequest cookies
- Category
- C#
- Title
- convert string array to int C#
- Category
- C#
- Title
- verifyusertokenasync password reset token
- Category
- C#
- Title
- unity make a int arry with preset values
- Category
- C#
- Title
- wpf c# select folder path
- Category
- C#
- Title
- load information with txt file to uwp c#
- Category
- C#
- Title
- how to edit a c# list
- Category
- C#
- Title
- bitmap to byte array c#
- Category
- C#
- Title
- c# resize image keep aspect ratio
- Category
- C#
- Title
- c# counting lines
- Category
- C#
- Title
- array copy c#
- Category
- C#
- Title
- nullable unique constraint ef
- Category
- C#
- Title
- windows forms iterate through all controls
- Category
- C#
- Title
- ubuntu: how zoom everything
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- C# get all child classes of a class
- Category
- C#
- Title
- unity how to set an objects postion x,y,z
- Category
- C#
- Title
- how to mock abstract httpcontext using moq .net core
- Category
- C#
- Title
- c# list to string join
- Category
- C#
- Title
- check if two timespans intersect c#
- Category
- C#
- Title
- unity 3d character controller
- Category
- C#
- Title
- c# multi threading example
- Category
- C#
- Title
- unity to integer
- Category
- C#
- Title
- dictionary update c#
- Category
- C#
- Title
- C# move form without border
- Category
- C#
- Title
- using in c#
- Category
- C#
- Title
- ping with c#
- Category
- C#
- Title
- mvc c# w3schools
- Category
- C#
- Title
- set object to random color unity
- Category
- C#
- Title
- how do loops on C#
- Category
- C#
- Title
- make a list c#
- Category
- C#
- Title
- c sharp how to read a text file
- Category
- C#
- Title
- unity get number of child objects
- Category
- C#
- Title
- is start called after dontdestroyonload
- Category
- C#
- Title
- increase variable C#
- Category
- C#
- Title
- c# check if argument null
- Category
- C#
- Title
- c# listview
- Category
- C#
- Title
- c# get index of item in list
- Category
- C#
- Title
- c# read char
- Category
- C#
- Title
- how to make % posibility to spawn an object C# in unity
- Category
- C#
- Title
- how to make a datatable in c#
- Category
- C#
- Title
- sort datatable c#
- Category
- C#
- Title
- c# main method
- Category
- C#
- Title
- unity how to change rotation
- Category
- C#
- Title
- error CS0542
- Category
- C#
- Title
- how to destroy a gameobject after some hits in unity 3d
- Category
- C#
- Title
- how to add an embedded resource in visual studio code
- Category
- C#
- Title
- how to crouch in unity
- Category
- C#
- Title
- initialize enum with another enum c#
- Category
- C#
- Title
- why is c# say ; expected
- Category
- C#
- Title
- transform.translate unity
- Category
- C#
- Title
- Check object is in layermask unity
- Category
- C#
- Title
- mailkit send attachment
- Category
- C#
- Title
- change textbox location C#
- Category
- C#
- Title
- find month number from date C#
- Category
- C#
- Title
- open link c#
- Category
- C#
- Title
- c# cheat sheet
- Category
- C#
- Title
- string.charat c#
- Category
- C#
- Title
- Unity if object doens't exist
- Category
- C#
- Title
- set textbox colour to transparent c#
- Category
- C#
- Title
- copy a list C#
- Category
- C#
- Title
- c# sort array
- Category
- C#
- Title
- unity set position
- Category
- C#
- Title
- mongodb c# batch find
- Category
- C#
- Title
- unity3d invector expand fsm controller
- Category
- C#
- Title
- C# array to label
- Category
- C#
- Title
- Replaced OS is obselete
- Category
- C#
- Title
- chase object unity
- Category
- C#
- Title
- c# method info extension
- Category
- C#
- Title
- how to deactivate objects through scripts in unity
- Category
- C#
- Title
- float to int c#
- Category
- C#
- Title
- c# class declaration
- Category
- C#
- Title
- how to convert iformfile to byte array c#
- Category
- C#
- Title
- how to find the type of a object c#
- Category
- C#
- Title
- message uwp c#
- Category
- C#
- Title
- check distance to gameobject
- Category
- C#
- Title
- or in unity c#
- Category
- C#
- Title
- send type as argument c#
- Category
- C#
- Title
- c# get date without time
- Category
- C#
- Title
- how to do a messagebox in c#
- Category
- C#
- Title
- set decimal point c#
- Category
- C#
- Title
- date time heutiges datum
- Category
- C#
- Title
- set label position winforms
- Category
- C#
- Title
- how to pass object as test case in nunit c#
- Category
- C#
- Title
- moq raise event
- Category
- C#