Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is the Difference B/W Finalize() and Dispose() in .Net?

Answer Posted / karna

when we write the destructor in c#,the runtime replaces the
destructor with the finalize method in IL code,so we dont
know at what time the destructor is called by the garbage
collector.so the finalizer is non deterministic.if we want
to do the garbage collection for unmanages resources,we
have to implement our own destructor or finlizer
method.but,the runtime will take two round trips to remove
those objects from the heap.if runtime calls the own
destructor,it will take onely one round trip.

to remove the unmanaged resources without the performance
issues,we have to inherit the System.Idisposable interface
and implement the Dispose() method.here one problem is
there,we have to write a code in a way that,the dsipose
method must and should execute.
for that reason we have to keep the dispose methos for the
objcets in the finally block.

problem with the dispose is that,some times because of
some problmes dispose() methos may not execute.
so the good practice is to use both to achieve the desied
performance.

Is This Answer Correct ?    20 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you initiate validation on the server manually? What are two situations when you might you want to do that?

1789


Difference between overriding and overloading?

1199


What does clearing cache?

917


What is difference cookie and session?

941


What is the size of Get method and how much data it can store?

1086


What is the difference between Hash table and Array list?

848


What are the differences between primary foreign and unique keys?

1031


What is the sequence in which ASP.NET events are processed?

1018


Why does my asp.net file have multiple tag with runat=server?

946


How do you implement postback with a text box?

951


List down the sequence of methods called during the page load.

861


Explain the difference between AutoPostBack and IspostBack in ASP.NET?

1035


What are demand-paging and pre-paging?

961


If there are multiple update panels on the page say upd1 and upd2. There is a button placed in upd1. How can you stop upd2 to update when button placed in upd1 is clicked?

951


Describe the diffeerence between inline and code behind?

965