Arena<T extends NativeType> class

Instead of doing many little allocations, Arena allocates a large chunk of memory which can be sliced into multiple ArrayViews. This can significantly improve performance and it makes memory management simpler.

final arena = Arena<Uint8>.allocate(10);
final array = arena.newArray(5);
final array2 = arena.newArray(5);
void some_native_c_api(array.ptr, array.length, array2.ptr, array2.length);
arena.delete();

Constructors

Arena(int length, [Pointer<T> allocate({int count})])
Arena.fromBuffer(Array<T> buffer)

Properties

buffer Array<T>
Pointer to allocated buffer
@protected, final
freeSpace int
Left free space of Arena.
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
length int
Total length of allocated memory
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

delete() → void
Deletes all allocated memory.
newArray(int length) ArrayView<T>
Returns a slice of length elements from the pre-allocated array of Arena. When length exceeds freeSpace it throws a RangeError.
@mustCallSuper
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited