This module takes you “under the hood.” To be a senior developer, you must understand not just how to write code, but how that code interacts with the physical hardware (RAM and CPU). This is the difference between an app that runs smoothly and one that crashes with an OutOfMemoryException.
The Common Language Runtime (CLR) is the “virtual machine” component of .NET. It sits between your compiled code and the Operating System.
.dll files into memory.Understanding how data is stored is critical for performance tuning.
int, bool, struct, enum): These hold the actual data. They are usually stored on the Stack. When you pass them to a method, a copy of the data is created.string, class, interface, delegate): These store a “memory address” (a pointer) to where the actual data lives. They are stored on the Heap. When you pass them to a method, you are passing the address, not the data itself.The computer’s RAM is divided into two main areas for your program:
In languages like C++, you have to manually delete objects from memory. In C#, the Garbage Collector does it for you. It uses a “Generational” approach to be efficient:
The “Stop-the-World” Event: When the GC runs a full cleanup, it sometimes pauses your application for a few milliseconds to move memory around. This is why high-frequency trading apps or games require “GC Tuning.”
Asynchronous programming (async/await) changes how memory is handled.
async method might “pause” while waiting for a database and resume later.await, the compiler transforms your method into a State Machine. It moves the local variables from the Stack to the Heap so they survive while the method is “waiting.”