Regarding functions
Why we use finalize and dispose functions separately
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pravin MoreRank #1,419 · 1.2K reputationPosted Sep 18, 2011, 8:48 PM EDT
There is diiference between finalize and dispose......
see Dispose() is normal method by which resourses are freed up from normal user code like internally via Close() method. Finalize() is used to clean resources in the cases when Dispose() is not get called like e.g case when there is some programming error.
hope m right....
Thanx,
Pravin.
Satish BhatRank #2,496 · 563 reputationPosted Sep 18, 2011, 8:56 PM EDT
Prabhu RajaRank #861 · 2.6K reputationPosted Sep 18, 2011, 9:12 PM EDT
Finalize () is called by Garbage Collector implicitly to free unmanaged resources. The garbage collector calls this method at some point after there are no longer valid references to the object. There are some resources like windows handles, database connections which cannot be collected by the garbage collector.
Therefore the programmer needs to call Dispose() method of IDisposable interface. Dispose () of IDisposable interface is called by the programmer to explicitly release resources when they are no longer being used. Dispose () can be called even if other references to the object are alive.
Thank You