Skip to content

chargeAllocation

function chargeAllocation(count, what): void;

Defined in: packages/engine/src/vm/AllocationBudget.ts:129

Record elements materialised by the evaluation in flight.

Each thing is charged exactly once, where it comes into existence: a matrix in matrixValue(), an expanded collection where it is expanded. A site that knows a size in advance and whose result will be charged on birth uses checkAllocation instead, so that refusing early does not mean counting twice.

Outside an evaluation this is a plain no-op rather than an error: matrixValue() and the vm/MatrixOps.ts helpers are exported and get called by tests, by the formatter and by hosts with no evaluation in flight, and none of those is user input being executed.

ParameterTypeDescription
countnumberHow many elements now exist.
whatstringWhat they are, in the plural and in a user’s words (“matrix cells”, “collection elements”). Quoted verbatim in the error, so it should name the thing rather than the code that makes it.

void

ALLOCATION_LIMIT_EXCEEDED when this evaluation has had enough. Recoverable: it describes this expression, not the engine.