为winform管理和非托管内存 [英] Manage and unmanaged memory for winform

查看:120
本文介绍了为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆