Glossary: Heap
OO codes are dynamic with
objects
being created and destroyed as required by the task in hand. Objects
require memory to hold their
data members.
For objects created dynamically there are two sources:-
- The stack - for short-lived objects
- The heap - for permanent objects.
The heap is a reserve area of memory with a manager that
allocates memory for an object's lifetime. The new operator gets memory from
the heap manager and the delete operator returns it. The lifetime of a heap
allocated object is only limited by the lifetime of the application. For
objects that only exist within a function, or generally any
compound statement
stack memory is better as its has a smaller allocation overhead.
See OO Concepts:Constructors & Destructors
Go Back to the
The Glossary Top Page
If you have any comments about this page please send them to
Nick West