Memory Allocation
Value types and reference types are allocated differently in memory. Value types are allocated in the stack. The stack is a memory area where methods are executed in 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 (pops) it from the stack together with its data and restores the previous state. Because of this ordered behavior, the stack is efficient, and the CLR can easily handle it. Consider the following ...
Get Visual Basic 2015 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.