Few Questions to Memory management in .net

I have read some Ideas about memory management in .net but following three question are unanswered to me

  • Unmanaged resources gets memory in same managed heap used for managed resources and who allocates it (OS OR CLR OR Anything else)?
  • Does calling Dispose() method on managed resource R, will immediately release memory occupied by this R and all other unmanaged resources occupied by R
  • Who Clears the memory occupied by unmanages resources (OS OR CLR OR Anything else).
  • Any help is welcome.


    1). The code which creates the unmanaged resource. For example, Win32 file handle is allocated by OS kernel.

    2). It's up to the implementation of Dispose method to free unmanaged resource. For example, it can call Win32 CloseHandle to close a file handle. Managed resource is still there, only freed through GC.

    3). Dispose method implementation, normally calling native functions.

    链接地址: http://www.djcxy.com/p/54536.html

    上一篇: 在具有Finalizer的类上调用.Dispose()

    下一篇: .net中对内存管理的几个问题