Chapter 10. Memory/Resource Management

In This Chapter

Much of the reason that managed code is called managed is because resources—and in particular, memory that is allocated by managed code—is managed. Responsibility for the deallocation of the memory does not rest with the programmer. With unmanaged code, all memory that is allocated requires the programmer to deallocate it. The CLR has a good scheme for managing the memory allocation and deallocation for an application. The CLR gives the programmer a world-class general-purpose garbage collector that frees the programmer from undue concern about memory allocation and deallocation. The strict type system in the .NET Framework ensures that code does not stray into memory in which it was not meant to be. One of the central focuses for this chapter is the general architecture for memory management within the .NET Framework.

Sometimes a programmer needs to take a proactive role in managing memory and resources. This chapter shows you how to gain more control over the garbage collector when it is too automatic. It is important to know what role the garbage collector plays and how you can efficiently manage resources other than memory within the .NET Framework. (Non-memory resources include file handles, database connections, Windows handles, and so on.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.8.247