I want to know about unmanaged resources.
Can anyone please give me a basic idea?
I want to know about unmanaged resources. Can anyone please give me a basic
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Managed resources basically means “managed memory” that is managed by the garbage collector. When you no longer have any references to a managed object (which uses managed memory), the garbage collector will (eventually) release that memory for you.
Unmanaged resources are then everything that the garbage collector does not know about. For example:
Normally you want to release those unmanaged resources before you lose all the references you have to the object managing them. You do this by calling
Disposeon that object, or (in C#) using theusingstatement which will handle callingDisposefor you.If you neglect to
Disposeof your unmanaged resources correctly, the garbage collector will eventually handle it for you when the object containing that resource is garbage collected (this is “finalization”). But because the garbage collector doesn’t know about the unmanaged resources, it can’t tell how badly it needs to release them – so it’s possible for your program to perform poorly or run out of resources entirely.If you implement a class yourself that handles unmanaged resources, it is up to you to implement
DisposeandFinalizecorrectly.