• 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.


    作者:ChenLuLouis
    出处:http://www.cnblogs.com/chenlulouis/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    该文章也同时发布在我的独立博客中-chenlulouisBlog

  • 相关阅读:
    vector与iterator的一些用法
    动态规划 hdu 1024
    dfs bfs hdu 1045
    hdu 2795
    poj 2828
    线段树染色
    线段树比大小
    A
    ?线程局部变量
    JRE、JDK、JVM 及 JIT
  • 原文地址:https://www.cnblogs.com/chenlulouis/p/2319285.html
Copyright © 2020-2023  润新知