記憶體回收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.

本節內容In this section

TitleTitle 描述Description
垃圾收集的基本概念Fundamentals of garbage collection 描述記憶體回收運作方式、如何在 Managed 堆積上配置物件,以及其他核心概念。Describes how garbage collection works, how objects are allocated on the managed heap, and other core concepts.
工作站和伺服器記憶體回收Workstation and server garbage collection 說明用戶端應用程式的工作站垃圾收集與伺服器應用程式的伺服器垃圾收集之間的差異。Describes the differences between workstation garbage collection for client apps and server garbage collection for server apps.
背景垃圾收集Background garbage collection 描述背景垃圾收集,這是層代0和1物件的集合,而層代2回收正在進行中。Describes background garbage collection, which is the collection of generation 0 and 1 objects while generation 2 collection is in progress.
大型物件堆積The large object heap 描述大型物件堆積(LOH),以及如何將大型物件進行垃圾收集。Describes the large object heap (LOH) and how large objects are garbage-collected.
記憶體回收和效能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

另請參閱See also