Memory allocation: Difference between revisions

m
No edit summary
Line 836:
=={{header|M2000 Interpreter}}==
Buffer is an object which hold a block of memory in heap. There are two types, the default and the Code type. In code type we can execute code, but at execution time we can't write to that block. So to get results from machine code we have to use a default type buffer (for data). Buffers used to read/write to binary files too.
 
[http://www.rosettacode.org/wiki/Machine_code#M2000_Interpreter See example for Machine Code]
 
If we use a wrong offset, buffer return error and locked (can't be used until erased)
 
Variable which hold the buffer is a pointer to buffer. The buffer erased when no more pointer points to it. We can use pointer as return value, or pushing to stack of values. We can use buffers as members of groups. A copy of group just copy the pointer. We can use buffers as closures in lambda functions, and a copy of lambda which have a closure of a buffer make a copy of pointer too (so two or more lambda function may use same memory allocation to read/write)
 
Buffers used with a type as a meter of bytes for each element, here in the example we say we have bytes. We can use Byte (1 bytes), Integer (2 bytes), Long (4 bytes), Double (8 bytes), or a structure (we can define structures, with pointer to strings also, as BSTR type). So if we use Integer as meter then Mem1(1)-Mem1(0) return 2 (2 bytes).
Data Byte, Integer, Long are unsigned.
 
We can redim buffers, but we can't change the meter. Structures can have unions to use different same data.
 
We can use Eval$(Mem1) to get a copy of a buffer in a string.
Statement Return used to place in many offsets data in one statement.
Line 858 ⟶ 865:
Checkit
</lang>
 
=={{header|Maple}}==
Maple is a garbage-collected language, so there is no direct control over the lifetime of objects, once allocated. When an object is allocated, it remains in memory until it is no longer reachable; then it is garbage-collected.
Anonymous user