Jump to content

Memory allocation: Difference between revisions

(added omit from ML/I)
(→‎{{header|Pascal}}: add example)
Line 410:
<lang parigp>allocatemem(100<<20)</lang>
to allocate 100 MB.
 
=={{header|Pascal}}==
 
=== Stack ===
 
Variables declared in procedures and functions are allocated on the stack.<br>
Their scope is local to the respective procedure/function and their memory is freed with the end of the procedure/function.
 
=== Heap ===
 
Dynamicly created objects (dynamic arrays, class instantiations, ...) are allocated on the heap.<br>
Their creation and destruction is done explicitly.
<lang pascal>type
TByteArray = array of byte;
var
A: TByteArray;
begin
setLength(A,1000);
...
setLength(A,0);
end;</lang>
 
<lang pascal>type
Tcl = class
dummy: longint;
end;
var
c1: cl;
begin
c1:=Tcl.create;
...
c1.destroy;
end;</lang>
 
=={{header|PicoLisp}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.