Skip to main content

Collections and caches

These tools are in the collections toolset. Starting the server with MEMLAB_TOOLSETS=collections exposes only them, plus the few tools every session needs, and memlab_tools({enable: "collections"}) turns them on in a session. Try them in the order listed.

ToolUse it when
memlab_collection_diffWHICH collections grew across a ladder, without being told their names — censuses every Map/Set/Array and keys each by a stable <Owner>.<property> signature. Flags rows keyed by per-request values (URLs with a query, ids, timestamps, counters) and append logs of timestamped records. detail: "rows" prints one verdict row per finding, without the prose.
memlab_weakref_censusEvery WeakRef, split LIVE vs EMPTY, grouped by the shape of the holder.
memlab_cache_analysisUnbounded or oversized caches in one snapshot.
memlab_collection_censusEvery collection with at least N entries at any depth, with an element split (null, holes, no-op wrappers, detached DOM, cancelled Scheduler tasks, top shapes) that flags rows at least 25% dead.
memlab_persistent_structuresHow many VERSIONS of a structurally-shared structure are retained (Immutable.js, Immer, RxJS) — detected by SHAPE, so it survives the minified class names a histogram cannot explain.
memlab_sparse_elementsInteger-keyed objects and arrays whose elements backing store is mostly holes — waste charged to no class, so a histogram cannot see it.
memlab_id_space_auditSeparate integer-keyed structures indexed by the SAME sparse id space — several small sparse findings that are really one re-keying fix.
memlab_stale_collectionsCollections holding entries nothing else references.
memlab_collection_trendThe same collections tracked ACROSS a ladder.
memlab_map_entriesEnumerate a Map/Set correctly: live entries vs deleted slots, small-integer keys and values, WeakRef slots, browser slot typing.
memlab_weakmap_entriesEnumerate a WeakMap.
memlab_array_group_byGroup an array’s elements by a property to see what is piling up.
memlab_property_distributionCardinality and top values of one property across instances.
memlab_field_fillEvery field of a record collection at once: % null, constant, empty, per-record copies vs shared, plus timestamp span / rate / age. Tells empty stubs and copied arrays from real content.
memlab_finished_stateObjects whose own status says FINISHED (traceStatus SUCCESS, completed:true, aborted, UPLOAD_PENDING, empty observers) but that still own big buffers, by holder; with 2+ snapshots, whether the buffer still grows. state: "pending": the inverse — started, never ended (a start clock and no end, an in-progress status), still owning a buffer: traces left open at rest.