Memory Allocation

Value types and reference types are differently allocated in memory. Value types are allocated in the Stack. The Stack is a memory area where methods are executed according to the last-in, first-out manner. The first method pushed to the Stack is the application entry point; that is, the Main method. When Main invokes other methods, the CLR creates a sort of restore point and pushes those methods to the Stack. When the method needs to be executed, data required by that method is also pushed to the Stack. When a method completes, the CLR removes (popping) it from the Stack together with its data, restoring the previous state. Because of this ordered behavior, the Stack is efficient, and the Common Language Runtime can easily ...

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.