About Garbage Collector?

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


Please Help Members By Posting Answers For Below Questions

What is the significance of proxy user?

803


What is the purpose of url encoding?

684


What is viewstate information stored?

833


Explain significance of routing? : asp.net mvc

788


What is a session in asp.net?

732


Is asp.net outdated?

711


Differentiate strong typing and weak typing

714


when a request is made in Life cycle of ASP.NET page .

711


What are navigation controls? How many navigation controls are there in ASP.NET 4.0?

717


What is the exact purpose of http handlers?

746


What language is asp.net written in?

755


Where sessions are stored?

859


What is a master page and what does it do?

708


What is redirecting behavior?

718


How does ASP.NET framework maps client side events to Server side events.?

763