zoukankan      html  css  js  c++  java
  • GC类

    GC类

      GC是一个静态类。

      

      垃圾回收器跟踪并回收托管内存中分配的对象。垃圾回收器定期执行垃圾回收以回收分配给没有有效引用的对象的内存。当使用可用内存不能满足内存请求时,垃圾回收会自动进行。或者,应用程序可以使用 Collect 方法强制进行垃圾回收。

      垃圾回收器不识别非托管代码中对对象的引用,因此,除非明确禁止,否则它有可能释放非托管代码中以独占方式使用的对象。KeepAlive 方法提供一种机制,该机制可防止垃圾回收器回收在非托管代码中仍使用的对象。

    1、AddMemoryPressure & RemoveMemoryPressure。

        

      

      In determining when to schedule garbage collection, the runtime takes into account how much managed memory is allocated. If a small managed object allocates a large amount of unmanaged memory, the runtime takes into account only the managed memory, and thus underestimates the urgency of scheduling garbage collection. The AddMemoryPressure method informs the runtime of this additional pressure on system memory.

      In the simplest usage pattern, a managed object allocates unmanaged memory in the constructor and releases it in the Dispose or Finalize method. Call the AddMemoryPressure method after allocating the unmanaged memory, and call the RemoveMemoryPressure method after releasing it.

    参考:http://msdn.microsoft.com/zh-cn/library/system.gc(v=vs.90).aspx

  • 相关阅读:
    UrlPathEncode与UrlEncode的区别
    大文件读取方法(C#)
    JavaScript与FileSystemObject
    ActiveXObject对象详解
    JS获取事件源对象
    实用JS大全
    设计模式的适用场景
    [转载]BigPipe技术
    window.location
    AJAX XMLHttpRequest
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3856034.html
Copyright © 2011-2022 走看看