記憶體回收Garbage Collection

.NET 的記憶體回收行程可管理應用程式的記憶體配置及釋放。.NET's garbage collector manages the allocation and release of memory for your application. 每次當您建立新的物件時,通用語言執行平台會從 Managed 堆積配置物件的記憶體。Each time you create a new object, the common language runtime allocates memory for the object from the managed heap. 只要 Managed 堆積中有可供使用的位址空間,平台就會繼續為新的物件配置空間。As long as address space is available in the managed heap, the runtime continues to allocate space for new objects. 不過,記憶體不是無限的。However, memory is not infinite. 因此記憶體回收行程最後就必須執行回收以釋放一些記憶體。Eventually the garbage collector must perform a collection in order to free some memory. 記憶體回收行程的最佳化引擎會根據所做的配置,決定執行回收的最佳時機。The garbage collector's optimizing engine determines the best time to perform a collection, based upon the allocations being made. 當記憶體回收行程執行回收時,會檢查 Managed 堆積中是否有應用程式不再使用的物件,並執行必要的作業以回收其記憶體。When the garbage collector performs a collection, it checks for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory.

標題Title 說明Description
記憶體回收的基本概念Fundamentals of Garbage Collection 描述記憶體回收運作方式、如何在 Managed 堆積上配置物件,以及其他核心概念。Describes how garbage collection works, how objects are allocated on the managed heap, and other core concepts.
記憶體回收和效能Garbage Collection and Performance 描述可用來診斷記憶體回收和效能問題的效能檢查。Describes the performance checks you can use to diagnose garbage collection and performance issues.
引發的收集Induced Collections 描述如何進行記憶體回收。Describes how to make a garbage collection occur.
延遲模式Latency Modes 描述判斷記憶體回收干擾程度的模式。Describes the modes that determine the intrusiveness of garbage collection.
共用 Web 裝載的最佳化Optimization for Shared Web Hosting 描述如何最佳化伺服器上由數個小型網站所共用的記憶體回收。Describes how to optimize garbage collection on servers shared by several small Web sites.
記憶體回收通知Garbage Collection Notifications 描述如何判斷何時接近完整的記憶體回收,以及何時已完成。Describes how to determine when a full garbage collection is approaching and when it has completed.
應用程式定義域資源監視Application Domain Resource Monitoring 描述如何監視應用程式定義域的 CPU 和記憶體使用量。Describes how to monitor CPU and memory usage by an application domain.
弱式參考Weak References 描述下列功能:允許記憶體回收行程回收物件,同時仍然允許應用程式存取該物件。Describes features that permit the garbage collector to collect an object while still allowing the application to access that object.

參考資料Reference

System.GC

System.GCCollectionMode

System.GCNotificationStatus

System.Runtime.GCLatencyMode

System.Runtime.GCSettings

GCSettings.LargeObjectHeapCompactionMode

Object.Finalize

System.IDisposable

另請參閱See also