chenlulouis

暴走笑话 杭州空调维修 杭州燃气灶维修 杭州洗衣机维修 上海ktv酒吧招聘 上海招聘 上海夜场招聘 上海夜场招聘

导航

Finalization / Freachable queue in .Net

When an application instantiates a new object, if the object's type defines a Finalize method, a pointer to the object is placed on the finalization queue just before the type's instance constructor is called. The finalization queue is an internal data structure controlled by the garbage collector. Each entry in the list points to an object that should have its Finalize method called before the object's memory can be reclaimed.

The garbage collector scans the finalization queue looking for pointers to the objects which are identified as garbage. And when found, it is moved to freachable queue which is another data structure maintained by garbage collector's internal. A special high-priority CLR thread is dedicated to calling Finalize methods and CLR uses a high priority thread to finalize these objects which appear in this freachable queue. The object in Freachable queue is reachable only to this finalization thread. So When writing the finalization method it should concentrate on disposing the local and native objects and shouldn't execute any that makes any assumptions about the thread that's executing the code.

posted on 2012-01-11 14:50  chenlulouis  阅读(604)  评论(0编辑  收藏  举报