What is Garbage Collection in .NET and Why do you care?

Bending the Clean Architecture principles

Anthony Trad
4 min readSep 8, 2022

Introduction

When crafting a new software, we always think and plan how we should create and implement things. Variables are everywhere in your code, but you really don’t know anything about them and simply use them.

However, knowing what’s happening under the hood would help you understand, optimize and level up your code. Soon enough, you’ll need to think about how things are done, and not only what to do!

What

.NET and C# removed lots of hassles and internal complexities in our development. At the end of the day, we only run, test, fix and optimize code.

In short, Garbage Collection (or GC) is a Memory Management tool for your application. GC will help you destroy that huge cached list when you’re done with it. It's like your neighbour volunteered to take out the trash of all apartments every now and then so you would never do it yourself. Isn’t that great?

How

As we already know, our variables are either stored on the Stack or on the Heap depending of their type and where they are defined. If you want me to write about that, feel free to share!

--

--

Anthony Trad
Anthony Trad

Written by Anthony Trad

Senior Software Engineer focused on .NET and the Cloud. Reconsidering major principles and patterns, ideas are my own.

No responses yet