Memory allocation: Difference between revisions
m
→{{header|Wren}}: Changed to Wren S/H
(Added Odin variant) |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 196:
% the memory allocated will now be garbage collected - there is no explicit de-allocation %
end.</syntaxhighlight>
=={{header|Arturo}}==
In Arturo, memory allocation is handled totally and exclusively by the VM, who is responsible for allocating and de-allocatiing memory when no longer needed, via the garbage collector.
The only way a programmer can "allocate" more memory is by flexible structures, like Blocks, and adding more elements to one of the pre-allocated structures:
<syntaxhighlight lang="arturo">
myBlock: @[1 2 3]
'myBlock ++ [4 5 6]
</syntaxhighlight>
=={{header|AutoHotkey}}==
Line 208 ⟶ 219:
The optional second parameter to Buff() allows you to specify the byte to be filled with (default is zero).
=={{header|
===
====Heap====
<syntaxhighlight lang="bbcbasic"> size% = 12345
DIM mem% size%-1
PRINT ; size% " bytes of heap allocated at " ; mem%</syntaxhighlight>
Memory allocated from the heap is only freed on program termination or CLEAR.
====Stack====
<syntaxhighlight lang="bbcbasic"> size% = 12345
PROCstack(size%)
Line 1,160 ⟶ 1,172:
=== Heap ===
Their creation and destruction is done explicitly.
<syntaxhighlight lang="pascal">type
Line 1,845 ⟶ 1,857:
The only type of memory allocation where the programmer has any control is the initial number of elements of a List though even here additional elements can be allocated by simply adding them.
<syntaxhighlight lang="
var squares = List.filled(10, 0)
// give them different values and print them
|