Manual memory management in .NET Framework
summary
Demo shows how to allocate and manipulate reference instances outside the GC by reading type handles, pulling object size from type metadata, copying or constructing instances into chosen memory, and pinning them; it uses TypedReference/__makeref and refvalue to get pointer-to-pointer indirections, emits IL to call constructors, inspects memory with WinDBG, and implements a custom allocator and an hijack new via machine-code patch so new routes to the allocator. Result: an unsafe contiguous-list insertion is ~3x faster, iteration similar, and objects behave with proper RTTI and syncblock semantics (but can crash).
AI-written summary · about
chapters (14)
- 0:00Start
- 1:16About Me
- 1:43Agenda
- 2:14Memory Structure
- 2:55Where Are Objects Stored in Dope Net
- 5:10Internals
- 9:41Make Ref
- 10:16Ref Value
- 11:52Generations in Dotnet Framework
- 12:55Demo
- 14:00Pointer Magic
- 14:35Type Safety
- 15:18Launch in Debug Attach to the Process
- 31:01Implement a Full-Blown Normal Memory Allocator in Net
related talks
48mManual Memory Management in .NET Framework
57mWriting a custom, real-world .NET GC
01h 00mMetaprogramming for the masses
01h 01mBoosting memory management in interoperability scenarios
57mMake your custom .NET GC — "whys" and "hows"
01h 05mLook Mommy, No GC!
53mDebugging .NET Apps
59mPragmatic memory management
