The Heap

The Heap

Many lectures in this course use memory diagrams to show how objects and variables are laid out on the stack and the heap. This lesson will lay down some groundwork and explain in detail what the heap is for, and how data on the heap is laid out in memory. 

 After completing this lecture you will have learned which data is stored on the heap and what happens when variables that refer to this data go out of scope. Finally, you will be able to explain what the 'Garbage collection' process does. 

 If you are already familiar with the internal workings of the heap in the .NET Framework, feel free to skip this lecture.

Write High Performance C# Code

Buy nowLearn more

Introduction

  • Course introduction
  • Introduction to code optimization
  • Windows, OS/X or Linux?

Fundamentals of the .NET Framework

  • Section introduction
  • Quiz 1: The Stack
  • The Stack
  • Quiz 2: The Heap
  • The Heap
  • Value types
  • Value types
  • Reference types
  • Reference types
  • Boxing and unboxing
  • Boxing and unboxing
  • Immutable strings
  • Immutable strings
  • Section recap

A crash course in Intermediate Language

  • Section introduction
  • Common Intermediate Language
  • Section recap
  • Common Intermediate Language

Basic optimizations: the low-hanging fruit

  • Section introduction
  • How to prevent boxing and unboxing
  • Fast string concatenation
  • Fast collections
  • Fast arrays
  • Throwing and catching exceptions
  • For versus Foreach
  • Section Recap
  • Basic optimizations

Intermediate optimizations

  • Section introduction
  • Fast Garbage Collection - part 1
  • Fast Garbage Collection - part 2
  • Fast delegates
  • Fast class factories
  • Section recap
  • Intermediate optimizations

Advanced optimizations

  • Section introduction
  • Arrays on the stack
  • Pointers - part 1
  • Pointers - part 2
  • Background Info - Modifying String Constants
  • Section recap
  • Advanced optimizations

Final words

  • Course recap