MemoryScratch class final

Pool of preallocated, reusable buffers for short-lived operations that need a temporary MemoryPointer without going through a full alloc/free cycle (e.g. binary operations like equality that need scratch space for one call).

Buffers are stack-allocated in LIFO order via acquire/ScratchHandle.release: a handle is only valid between its own acquire and release, and must be released before any handle acquired before it. Releasing out of order is a programming error and throws StateError.

Lifecycle is tied to the backend, not to this class directly.

Not instantiatable, use as a static namespace.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

acquire<Y extends RType>({int? sizeInBytes}) → ScratchHandle<Y>
Claims the next scratch slot on the stack, allocating a new backing buffer if the stack has never reached this depth before.
dispose() → void
Frees all backing allocations and empties the pool. Any outstanding ScratchHandle becomes dangling, callers must not hold handles across a backend lifecycle boundary.