Arena<T extends NativeType> class

Instead of doing many little allocations, Arena allows you to make one large allocation which can then be sliced. This can improve performance and simplify memory management.

final buffer = Uint8Array.allocate(10);
final arena = Arena(buffer, buffer.ptr.size);
final array = arena.newArray(5);
final array2 = arena.newArray(5);
void some_native_c_api(array.ptr, array.length, array2.ptr, array2.length);
arena.free();
Annotations
  • @sealed

Constructors

Arena(Array<T> _buffer, {required int elementSize})
Allocates a buffer of length

Properties

freeSpaceLeft int
Left free space of Arena
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

free() → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
slice(int length) → Slice<T>
Returns a view into _buffer. When length exceeds freeSpaceLeft it throws a RangeError.
toString() String
A string representation of this object.
inherited

Operators

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