Answer Posted / sayeed
Garbage collection is an in deterministic process Associated
with CLR. It is used to release the managed free Objects
that are no more refrenced.
But there might be scenarios in which we need to release
certain resources held by an object (like a database
connection) once the object is no longer in use.
We have destructors in C#.C# destructors are nothing but
finalize methods in disguise, with a call to base class's
finalize method.
As we know, finalize method is called during garbage
collection by garbage collector. Hence, we cannot rely only
on C# destructors to explicitly release resources as
finalize methods on objects may never be called altogether
(if the program terminates abnormally) or might be called
only when the program terminates (in a normal way).
Hence it is always a good practice to implement IDisposable
interface in such cases and to write code to release
resources explicitly in the Dispose() method.In that case we
have to use GC.SuppressFinalize() method.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is difference between cookies and cache?
What is the base class from which web forms are inherited?
What is difference Between Authentication and authorization?
How many types of state management are there in asp net?
What is the request flow used for asp.net mvc framework? : asp.net mvc
How ViewstateMac works?
What do you mean by query string?
Tell me the code snippet to show how we can return 404 errors from HttpError?
How to automatically get the latest version of all the asp.net solution items from source safe when opening the solution?
What is .net remoting?
How to set the pane area to transparent of a scrollPane component.?
Is razor a programming language?
Explain the role of global.asax?
What is globalization and localization in asp net?
Which protocol is used to call a web service?