377 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.
RAM, the stack and the heap, registers, CPU caches (L1, L2, L3), cache misses, memory alignment, pointers and references in .NET.
How the call stack and the managed heap work, what goes in each (locals, frames, objects, boxed values, captured variables, async state), why "value types live on the stack" is a myth, and the performance and lifetime consequences.
The spectrum from safe object references to managed pointers (ref, in, out, ref locals and ref returns, ref fields in ref structs) to unmanaged pointers in unsafe code, how the GC tracks and moves them, pinning, and when each is appropriate.
The levels of the memory hierarchy with realistic sizes and latencies, why caches exist, how cache lines and associativity work, what is private versus shared between cores, TLBs, and how the hierarchy shapes the performance of everyday .NET code.
Types of cache misses (compulsory, capacity, conflict, coherence) and TLB misses, the symptoms of memory-bound code, how to measure misses on Windows and Linux for .NET processes, and the design changes that reduce them.
Natural alignment, padding and why misaligned access is slow or non-atomic, how the CLR lays out classes (auto) and structs (sequential by default, auto when they contain references), object headers and minimum object size, measuring sizes, and using StructLayout, FieldOffset, Pack and InlineArray for interop and performance.
How the call stack overflows, why .NET terminates the process instead of letting you catch it, common causes (unbounded or deep recursion, self-referencing properties, cyclic object graphs, large stackalloc), and how to diagnose with crash output, dumps and tests.
Process memory from the operating system's and the runtime's point of view: physical RAM versus virtual address space, working set, private and committed memory, the GC heap and native memory, container cgroup limits, GC heap hard limits, Server GC and DATAS, and a step-by-step investigation of OOMKilled pods.
How allocation works on the managed heap (bump-pointer allocation in per-thread contexts), how generations and promotion keep collections cheap, when objects go to the large object heap, why pinning matters and the pinned object heap, and how to measure and reduce allocations.