O'Reilly logo

.NET Programming: A Practical Guide Using C# by Pradeep Tapadiya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Automatic Memory Management

Every program stores instances of datatypes in memory. This per-instance memory can be allocated either in the data segment, the stack, or the heap. Typically, static variables in a program are stored in the data segment and local variables to a method are stored on the stack. The compiler inserts appropriate logic in the output code to deal with memory management of data-segment-bound and stack-based types. For heap-based types, a programmer has to explicitly deal with memory management issues. Here are the typical steps a programmer goes through to deal with heap-based types:

1.
Allocate memory of proper size for the instance of the type. Under C++ and C#, for example, this can be done using the operator new.
2. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required