MemoryBudget class final
How much memory may be held, per MemoryCategory and in all, and what is held now.
An account, as MemoryReport is: a cache charges what it loads by
its own estimate of the value (ResourceCache.sizeOf) and refunds it
when the value leaves, so the budget holds the bytes the data needs, the
floor every backend sits on, and nothing a driver adds behind it.
It says when a limit is crossed; a cache acts on it. A
ResourceCache given this budget evicts what nobody holds, least wanted
first, until it is back under; what is held stays, and the budget stays
over until something is released. onCrossed hears each crossing once,
going over and coming back, so a game can lower its texture quality or
stop streaming the moment it matters rather than polling.
One budget may be shared by several caches: the models and the textures of a level against one limit for the level.
Constructors
-
MemoryBudget({Map<
MemoryCategory, int> limits = const {}, int? total}) -
A budget with a limit per category in
limits, in bytes, and atotalover all of them; a category without a limit has none.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- total → int?
-
The most every category may hold together, in bytes, or null for no
limit beyond the categories' own.
final
- used → int
-
What every category holds together, in bytes.
no setter
Methods
-
charge(
MemoryCategory category, int bytes) → void -
Puts
bytesoncategory's account. -
isOver(
{MemoryCategory? category}) → bool -
Whether
categoryis over its limit, or with no category, whether the total is. -
isOverFor(
MemoryCategory category) → bool -
Whether
categoryor the total is over, which is what a cache holdingcategoryhas to bring down. -
limitOf(
MemoryCategory category) → int? -
category's limit in bytes, or null when it has none. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCrossed(
void handler(MemoryBudgetCrossing crossing)) → Registration -
Calls
handlereach time a category or the total crosses its limit, either way, until the registration is canceled. -
refund(
MemoryCategory category, int bytes) → void -
Takes
bytesoffcategory's account. -
toString(
) → String -
A string representation of this object.
override
-
usedOf(
MemoryCategory category) → int -
What
categoryholds now, in bytes.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited