Heap: Difference between revisions

Content added Content deleted
(Computer engineers are good for something)
 
No edit summary
Line 4: Line 4:


Memory not allocated on the heap is allocated on the [[system stack]], and includes things like subroutine return values and parameters, the return address of a subroutine, and local temporary variables, among other things.
Memory not allocated on the heap is allocated on the [[system stack]], and includes things like subroutine return values and parameters, the return address of a subroutine, and local temporary variables, among other things.

In typed languages objects created in the heap are usually allocated by the operator '''new''' or equivalent. Then they are '''constructed''' (or else initialized) in place. Before deallocation objects are '''destructed''' (finalized).

The heap must be interlocked when accessed from multiple [[task]]s (see also [[concurrent programming]]).

Some languages like [[Ada]] provide user-defined heaps, called '''storage pool''' (so the ''heap'' becomes merely a predefined storage pool.) The programmer may implement a better memory allocation and reclamation strategy for such pools, when he knows the behavior of the objects allocated there. For example: arena, [[LIFO]] etc.