Automatic Memory Management

Another core service provided by the runtime’s execution engine is garbage collection. Historically, memory management has been a painful business for developers. Often, error-prone code results, and even the simplest code gets bloated by low-level bookkeeping code. On top of that, direct pointer manipulation isn’t exactly appropriate in a world where memory safety and type safety are to be maintained.

Previous approaches to memory management were either too low-level (such as malloc/free in C and new/delete in C++), causing bugs such as dangling pointers and double frees, or reached their limits if things got too complex (such as the inability to reclaim cyclic references in the world of COM’s AddRef/Release reference ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.