Skip to main content

Module memory

Module memory 

Source
Expand description

The memory report behind qjs -d / --dump and JS_ComputeMemoryUsage.

§Why this is a walk and not a set of counters

Tracking every number the reference tracks would mean a counter incremented at each of the two hundred places that define a property or push an element, and one forgotten site makes the report quietly wrong — the exact failure mode Heap::measure_used avoids for the memory limit (see its comment). So the numbers here are measured: walk the live boxes once, downcast, and add up. JS_ComputeMemoryUsage in the reference is also a walk over its object lists, so this is the same design rather than a substitute for it.

§What is real and what is zero

rowhow
memory allocatedthe heap’s live registry; headers plus payload
stringsevery live JsString, by byte length
objectsevery live JsObject
propertiessum of props.len() over those objects, by slot capacity
shapesalways 0 — this engine has no hidden-class sharing
bytecode functions, bytecodelive CompiledCode, by instruction bytes
C functionscallables that are native or host closures
arrays, fast arrays, elementsObjectKind::Array and its element vector
binary objectsArrayBuffer, TypedArray, DataView
atomsnot printed — property keys are ordinary strings here

A zero that means “not modelled” is labelled as such in the rendered report, because the one thing worse than a missing number is a wrong one that looks measured (docs/test262-status.md §4.37).

Structs§

ClassCensus
The per-class census that the reference prints between the header and the table.
MemoryUsage
What one runtime occupies, in the reference’s JSMemoryUsage field names.

Functions§

compute
Measure heap.
dump
One context’s report, as qjs -d prints it.