为winform管理和非托管内存 [英] Manage and unmanaged memory for winform
问题描述
我有很多疑问?
如何为winform(.NET)释放管理和非托管内存。
how to free manage and unmanaged memory for winform (.NET).
推荐答案
Hello than ke,
Hello Than ke,
托管 内存,托管资源的回收不需要人工干预。这是垃圾收集 。它为您的应用程序管理分配和
可用内存。当不再引用对象时,GC将(最终)释放已分配给它们的内存。
For managed memory, recycling of managed resources does not require manual intervention.This is a job of Garbage Collection . Which manages the allocation and free memory for your application.When objects are no longer referenced and GC will (eventually) free the memory that had been allocated to them.
For unmanaged内存,unManaged对象是在.NET库的控制之外创建的,不受CLR管理,这种非托管代码的例子是COM对象,文件流,连接对象,Interop对象。有一个一些
方式来清理非托管资源。
For unmanaged memory,unManaged objects are created outside the control of .NET libraries and are not managed by CLR, example of such unmanaged code is COM objects, file streams, connection objects, Interop objects.There are some ways to cleanup unmanaged resources.
- 实现IDisposable接口和Dispose方法
- '使用'block也用于清理非托管资源
此致,
Neil Hu
这篇关于为winform管理和非托管内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!