Discussed below topics
1) What is Finalize and how to create ?
2) What is Destructor and purpose?
3) IDisposable interface
3) Using block
4) What is GC.Collect?
5) Why and when to use GC.suppressfinalize
6) Dispose Vs Finalize
7) GC Performance differences between Dispose or Finalize.
Nguồn:https://wijstaanvooronzegrondrechten.org/
Thank you for a good explanation with illustrations!
Note for myself: dùng GC.SuppressFinalize(this) để kêu GC đừng có chạy cái logic trong Finalize aka Destructor (ví dụ như đừng có đẩy object this này vô cái Finalize queue rồi GC sẽ deallocate unmanaged memory)
Để ý trong Détructor() chỉ có logic để deallocate unmanaged memory thôi. Còn trong Dispose() chỉ có logic để deallocate managed memory thôi, và phải call SuppressFinalize() để GC đừng đụng gì đến unmanaged mem.
What happens to an object when usually we don’t provide a Destructor? How is it different with when we explicitly provide a Destructor?
Like this video
Excellent
Hi, why should we use dispose for managed code, if the GC automatically free the heap memory if the instance is not referring by any object in stack? Please explain sir
Great Explanation. Thank you
Well explained. Clear the difference between Dispose and Finalize method
Well explained!!
Well explained.. Have a question.. when a class has Destructor GC will move the object to Finalize queue. Let's say user forgot to call the Dispose. Finalize will be called which will call Dispose(false) which will clear only unmanaged code. In this case how GC will clear the managed objects(object is in Finalize queue). Will the object comes back to Gen 0/1 once the Destructor is called?
Thanks
Awesomeee Sir,
Reallyyy made it easy to understand,
Now I can face this question anytime 🙂
Thanks a lot Sir.
Expecting more such concepts clearing videos from you.
very nice video
Nicely explained. Got my concepts cleared.
Mind Blowing , Fantastic , awesom explanation bro .Thanks for your IQ. Please Keep Share ike these videos.
Bro nice explanation initially i down voted but after watching the full 1 i up voted .
Nice video
Really nice explanation.. Have a good understanding of GC now 🙂 Thanks!
Very well explained. Cleared all the concepts of deallocating the objects for managed and unmanaged objects.
Great one…. now I'm clear about GC. Good Vedio
Thanks for such an informative, helpful and simple explanation…..
very good and informative..Thanks Ramana
Awesome …. Thanks
Nice explanation 🙂
Thanks Ramana, nice video …
Great efffort, Raman. Helped me understand the garbage collection concept pretty well. Thank you.
Very good tutorial!! Thank you!! 🙂
That's great….Thankx it helped a lot.
Useful,,Thanks
appreciate your efforts . educational ty )
Dispose just executes the code inside, it will NOT release the current object itself unlike the finalize. Note that for finalize, finalize is called just before the object is to be released.
Nice Vedio, Now i got clear picture of implementing Disposable and Finalize exact scenario's Thanks
Never thought about thread safe disposing. Quick question, what book did you study to get this kind of in depth knowledge?
Thank you so very much!!!! Finally I got finalize and dispose in my head, I had read many blogs but all were confusing…Thanks again..
Best video on finalize vs dispose
very very helpful…nice video . thanq u …
Very Practical …. ThanQ