Chapter 18. Unsafe Code

Unsafe code can access unmanaged memory, which is outside the realm of the Common Language Runtime (CLR). Conversely, safe code is limited to accessing the managed heap. The managed heap is managed by the Garbage Collector, which is a component of the CLR. Code restricted to the managed heap is intrinsically safer than code that accesses unmanaged memory. The CLR automatically releases unused objects, performs type verification, and conducts other checks on managed memory. This is not done automatically for unmanaged memory; rather, the developer is responsible for these tasks. With managed code, developers can focus on core application development instead of administrative tasks such as memory management. For this reason, ...

Get Programming Microsoft® Visual C#® 2008: The Language 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.