just_memory library
Memory-management primitives for games and other real-time Dart code.
- ObjectPool, RoundRobinPool and PriorityPool reuse objects instead of allocating new ones; PoolManager shares them by name.
- MemoryScope runs a lifetime's cleanup steps together.
- RefCountedRegistry loads shared resources once and frees them after the last holder lets go.
- BudgetedCache is an LRU cache bounded by total cost.
- MemoryArena, TypedVec2, TypedTransform and TypedBuffer keep hot numeric state in flat typed arrays.
- MemoryProfiler and LeakTracker show what is held and what leaked.
Classes
- ArenaStats
- The occupancy of one MemoryArena, as reported by PoolManager.getArenaStats.
-
BudgetedCache<
K, V> - A least-recently-used cache bounded by total cost rather than entry count.
- CacheBudgetStats
-
The size and budget of one
BudgetedCacheat one moment. - LeakTracker
- Counts objects that were created but never disposed, by label.
- MemoryArena
- Fixed-size, contiguous numeric storage for entity-like state.
- MemoryCleanupResult
- What a MemoryProfiler cleanup touched.
- MemoryProfiler
- Watches named pools and caches and captures their counters on demand.
- MemoryProfileSnapshot
- The counters of a MemoryProfiler's pools and caches at one moment.
- MemoryScope
- Groups cleanup steps that share one lifetime (a scene, a subsystem) and runs them together, last registered first.
- MemoryStats
-
The counters of one
ObjectPoolat one moment. -
ObjectPool<
T> -
A pool that hands out reusable objects of type
Tand takes them back. - PoolManager
- A process-wide registry of named ObjectPools, MemoryArenas and RoundRobinPools, so systems can share them by name.
- PoolStats
- The counts of one ObjectPool, as reported by PoolManager.getPoolStats.
-
PriorityPool<
T> - A pool that, when empty, can take back its lowest-priority object.
- Recyclable
- Interface for objects that can clear their mutable state before reuse.
-
RefCountedRegistry<
K, V> - Shares loaded values between holders and frees each one after its last holder lets go.
-
ResourceHandle<
K, V> - One reference to a value held by a RefCountedRegistry.
-
RoundRobinPool<
T> - A fixed ring of objects handed out in turn.
- SystemMemorySnapshot
-
The host's memory figures at one moment, as read by
MemoryProfiler.captureSystemMemory. -
TypedBuffer<
T extends num> - A fixed-capacity numeric buffer backed by a Float64List, Float32List or Int32List.
- TypedTransform
- A view of one MemoryArena slot as a 2D transform (position, rotation, scale, velocity), using the arena's transform layout.
- TypedVec2
- A 2D vector stored in two components of a MemoryArena slot, or in its own fields when made with TypedVec2.temp.
Typedefs
-
CostEstimator<
K, V> = int Function(K key, V value) - Returns what an entry costs against a BudgetedCache's budget (bytes, pixels, or any unit). Must not be negative.
-
DisposeCallback
= FutureOr<
void> Function() - A cleanup step owned by a MemoryScope; may be asynchronous.
-
EvictionCallback<
K, V> = void Function(K key, V value) - Called with an entry that has left a BudgetedCache.
-
ResourceDisposer<
V> = FutureOr< void> Function(V value) - Frees a value once nothing holds it any more.
-
ResourceLoader<
K, V> = FutureOr< V> Function(K key) -
Loads the value for
key; may be synchronous or asynchronous.