Coding Shorts 110: Garbage Collector and IDisposable

preview_player
Показать описание
Don't miss my upcoming "Pragmatic Architecture for ASP.NET Core" workshop coming November 11th:

Recently I noticed some developers seem to be confused about the relationship between the Garbage Collector and the IDisposable interface. For good measure, I show you how value types vs. reference types work too!

00:00 Introduction
01:19 The Project
01:52 Memory and GC
03:53 Adding IDisposable
05:52 Using a Using Statement
06:31 Using the Dispose Pattern
07:35 To Finalize or Not
12:16 What about Records?
12:32 And Structs?
13:07 Finally, record struct
13:27 Wrapping Up

For more information about my training and coaching, visit:

If you like this video, you might like other videos in my Instructional Videos:
Рекомендации по теме
Комментарии
Автор

Thank you, Shawn, for years you are in my opinion one of the top best teachers on Pluralsight. God bless you and your loved ones and thank you for sharing knowledge

lyudmilpetrov
Автор

What a pleasant thing to wake up to. Great vid Shawn.

PicaPauDiablo
Автор

Your videos are Gold. And C# is maybe de most flexible and powerful language I've ever used.
A while ago, I tried Golang, another powerfull language, but C# has a powerfull tool that Golang doesn't, JIT compiler. It makes C# powerful, because you can use it without recompilation on multiple systems, but if needed, C# also supports AOT (instead of JIT), and could be as fast as Go, ando even faster.
A lot of caracteristics of C# makes it language beautiful (and my favourite), GC, Reflection, Expression Trees, AOT, JIT, Code Generators, full (or almost full) functional support (I still waiting for Union Types), App Domain, unsafe, pointers, etc.. I really love C# and its ecosystem (.NET and its VBasic and F# compatibility).
Keep going, your videos are great!

lacuevadelinsecto
Автор

Awesome video, I think I will add a couple questions to our interview process after this :) I agree with the statement that even seniors soemtimes say things like "you need to add IDisposable for garbage collector to clean up the object"

Qrzychu
Автор

Super helpful and cleared up for me how finalizers fit with IDisposable. Thank you!

Very minor request: consider using larger text to help us old guys watching on our phones.

Rhysling
Автор

Thank you Shawn. Great explanation of this mechanism. Really cool that you showed it with diagnostics counters.

nico-toscani
Автор

Fantastic video and very pertinent to an app I'm building at work!

Soupflakez
Автор

thanks for the video.. i totally agree on that, even some of the senior devs of the company i was working with didnt know the exact reasons or only the half of it which what seperates gc and idisposable etc. MSDN docs also have a very good explanation for this, which i recommend any c# dev to read.

AtikBayraktar
Автор

excellent and clear explanation as always!

hc-jcoc
Автор

Thanks a lot Shawn
I hope you create a video about when to use class, record, struct, class struct and record struct

Tamer_Ali
Автор

Thank you, excellent.

If we have events (the += type), where should they be cleaned up, and is that needed?

JonathanPeel
Автор

Sometimes I wonder how each iteration of WPF's TreeView handles it's memory...

Anyway, great video Shawn 👍

gabe_x