Understanding Memory Allocation

Chapter 4, “Data Types and Expressions,” discusses value types and reference types, describing how both of them are allocated in memory: Value types reside in the stack whereas reference types are allocated on the managed heap. When you create a new instance of a reference type, via the New keyword, the .NET Framework reserves some memory in the managed heap for the new object instance. Understanding memory allocation is fundamental, but an important practice is to also release objects and resources when they are unused or unnecessary. This returns free memory and provides better performances. For value types the problem is of easy resolution: Being allocated on the stack, they are simply removed from memory ...

Get Visual Basic® 2010 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.