When should we do memory management and How do we do it for both the types of resources?
What is the list of managed and unmanaged resources?
Do we really need to worry about memory leaks or not?
When should we do memory management and How do we do it for both
Share
Managed resources are those that are fully written in .NET. Though not normally subject to classic memory leaks, one can still leak memory by not dereferencing unused resources (the most common reason is to not un-register event handlers).
Unmanaged resources are those that are generally those that are not pure .NET (and in the same process) – examples are:
For these, you need to implement the
Disposepattern, correctly and ensure proper disposal when you have finished using them.Yes, we do need to worry about them, in particular when going outside of .NET.