Heap: Difference between revisions

298 bytes added ,  15 years ago
m
A little English
No edit summary
m (A little English)
 
(One intermediate revision by one other user not shown)
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.
 
There exist various algorithms of heap maintenance to respond the major problems of:
 
* fragmentation;
* unbounded allocation or else deallocation time.
 
Often the language uses more than one heap. One frequently used method is to have a heap for blocks of similar sizes, typically powers of two.
 
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).
Line 9 ⟶ 16:
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 poolpools''' (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.
Anonymous user