Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
C# Memory Tricks: Learn How To Master The Garbage Collector
Rating: 4.6 out of 5(1,729 ratings)
9,998 students

C# Memory Tricks: Learn How To Master The Garbage Collector

This course teaches you advanced C# memory management tricks that every professional .NET developer must know.
Created byMark Farragher
Last updated 5/2026
English

What you'll learn

  • Learn how the Garbage Collector works
  • Master .NET memory optimization
  • Discover the truth about finalizers
  • Learn how to measure the memory footprint of your code
  • The unexpected memory footprint of List resizing
  • Structs versus classes - which one is better?
  • What assumptions does the GC make about object size and lifetime?
  • Manual deallocation with the Dispose pattern
  • ... and much more!

Course content

5 sections28 lectures3h 31m total length
  • Course Introduction4:12

    In this lecture I explain how this course is organised and I describe each of the upcoming sections in detail.

  • Meet Your Instructor3:50

    In this lecture I will tell a bit more about myself, my career, and my motivation to become an online trainer.

  • Introduction To .NET Memory Management4:17

    In this lecture we're going to look at the theory behind .NET memory management. What exactly is Garbage Collection, and how does it work?

  • Windows, OS/X or Linux?3:19

    Many lectures in this course contain source code examples. Feel free to download the code and follow along. And here's the good news: it doesn't matter if you have a Window, Mac or Linux computer. The code will run on all three operating systems.

    In this lecture I demonstrate how my solutions and projects run on all operating systems. I will show you how to build and run the source code on a Mac, on Linux and in Visual Studio running on Windows 8.

    At the end of this lecture you will have learned that .NET code is portable and can run on at least five different operating systems.

  • Background Info - About Me1:14

Requirements

  • You need a Windows, Mac or Linux laptop with Microsoft Visual Studio, Xamarin Studio or Monodevelop
  • You should be a beginner, intermediate, or advanced C# developer
  • That's it!

Description

Modern computers have loads of memory. But it's very easy to burn through it all in seconds if your code is not efficient about allocating and using memory.

Did you know that one simple mistake can make your code allocate 1600 times more memory than absolutely necessary?

Don't be 'that developer' who keeps crashing the development server with an OutOfMemory exception!

And you certainly don't want to be responsible for inflating the hardware budget. Can you imagine having to explain to your team that 512 GB of memory is not enough to run your code on the production server?

Let me help you.

It doesn't have to be like this. If you have a good understanding of the garbage collection process and follow a few simple best practices, you can dramatically reduce the memory footprint of your code.

Sound good?

In the last 10 years I have learned the secrets of garbage collection in .NET, and in this course I am going to share them all with you.

In a series of short lectures I will take a detailed look at the garbage collection process. I will show you all of the memory allocation problems you can expect when writing C# code, like unexpected boxing, string duplication, collection resizing, and more. I'll teach you quick and easy strategies to resolve these problems.

By the end of this course you will be able to master the garbage collector.

Why should you take this course?

You should take this course if you are a beginner or intermediate C# developer and want to take your skills to the next level. Garbage collection and memory management might sound complicated, but all of my lectures are very easy to follow and I explain all topics with clear code and many instructive diagrams. You'll have no trouble following along.

Or maybe you're working on a critical section of code in a C# project, and need to make sure your memory usage is as efficient as possible? The tips and tricks in this course will help you immensely.

Or maybe you're preparing for a C# related job interview? This course will give you an excellent foundation to answer any questions they might throw at you.

Who this course is for:

  • Beginner, intermediate, and advanced C# programmers who want to learn how to master the garbage collector.
  • Developers who are about to take a job interview and need to prepare for questions about memory allocation in .NET
  • Professionals who are writing a section of mission-critical code in a large C# project