其中管理类的.NET Framework分配(或使用)非托管内存?管理类、分配、内存、Framework

2023-09-03 05:03:32 作者:满是遗憾

是否存在已知的(记录)的.NET类型,在进程的内存中的非托管部分?

Is there a known (documented) set of .NET types that allocate memory in the unmanaged portion of the process' memory?

例如,该WPF基础设施,以便分配的非托管内存为它保留的渲染模型微软的文档来优化性能。是否有.NET framework的,利用大量的非托管内存等其他部分?

For example, Microsoft documents that the WPF infrastructure allocated unmanaged memory for its retained rendering model in order to optimize performance. Are there other such portions of the .NET framework that utilize large amounts of unmanaged memory?

推荐答案

如果它实现的IDisposable 有一个非常好的机会,它拥有的非托管数据,或者它拥有一个管理类,最终拥有非托管数据。如果有的Finalize(),它的标志,它直接拥有的非托管数据。

If it implements IDisposable there is a very good chance it owns unmanaged data, or it's owning a managed class that ultimately owns unmanaged data. If it has Finalize(), it's sign that it directly owns unmanaged data.

作为一个经验法则,如果它实现的IDisposable ,然后的Dispose()只要你是大功告成。

As a rule of thumb, if it implements IDisposable, then Dispose() it as soon as you're done.