The Stack

The Stack

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 stack is for, and how data on the stack is laid out in memory.  


 After completing this lecture you will have learned which data is stored on the stack and what happens when this data goes out of scope. Finally, you will have seen a Stack Overflow exception, and know how to avoid this exception in your own code. 

 If you are already familiar with the internal workings of the stack 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