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

Explain the role of global.asax?

997


What are session and cookies?

987


What is a web server? What are the load limits in it?

1132


What does occur first in ASP.Net, Authentication or Authorization?

1036


How Can assign alias name for ASP.NET Web API Action?

1455


How does session authentication work?

928


How many types of cookies are there in asp.net?

953


How to Insert/Add in ASPXgridview

1037


What is the use of asp.net web api?

1096


How to count the number of objects present in a web page? How to count the number of radio buttons in a web page?

1098


Explain the difference between debug.write and trace.write? When should each be used?

1007


What is an asp.net validator? And, mention its types.

1025


What is the difference between Classic ASP and ASP.Net?

1106


How do we access view state value of this page in the next page?

1001


Can the unique key be null?

1109