Difference between revisions of "Heap"
m |
m |
||
Line 14: | Line 14: | ||
In this example variable ''i'' is declared as an integer and allocated to all processes (by default) and also on the heap. Note how we have omitted the optional braces to the ''stack'' type as there are no arguments. | In this example variable ''i'' is declared as an integer and allocated to all processes (by default) and also on the heap. Note how we have omitted the optional braces to the ''stack'' type as there are no arguments. | ||
− | ''Since: Version 0 | + | ''Since: Version 1.0'' |
== Default allocation strategies == | == Default allocation strategies == |
Revision as of 18:21, 13 January 2013
Syntax
heap[]
Semantics
Instructs the environment to bind the associated variable to heap memory which exists regardless of runtime context.
Note: All heap memory is garbage collected. The specifics of this depends on the runtime library, broadly when it goes out of scope then it will be collected at some future point. Although not nescesary, you can assign the null value to the variable which will drop a reference to the memory.
Note: This type, used for function parameters or return type instructs pass by reference
Example
var i:Int :: allocated[heap];
In this example variable i is declared as an integer and allocated to all processes (by default) and also on the heap. Note how we have omitted the optional braces to the stack type as there are no arguments.
Since: Version 1.0
Default allocation strategies
Type | Default allocation strategy |
---|---|
All element types | Stack |
Array | Heap |
Record | Stack |
Reference record | Heap |