Heap: Difference between revisions

298 bytes added ,  15 years ago
Added: fragmentation, multiple heaps, construction-destruction, multitasking, user-defined heaps
No edit summary
(Added: fragmentation, multiple heaps, construction-destruction, multitasking, user-defined heaps)
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).