MemoryBudgetManager.OnOverBudgetListener
public
static
interface
MemoryBudgetManager.OnOverBudgetListener
| android.app.MemoryBudgetManager.OnOverBudgetListener |
The callback that is notified when a memory budget is exceeded.
Callbacks are invoked repeatedly (debounced to at most once per second) on the
Looper supplied at registration while the monitored package or
process exceeds its budget. Register listeners on a background
HandlerThread Looper rather than
Looper.getMainLooper() or null (which defaults to
the main Looper), and avoid contended locks, blocking I/O, allocations, or
full-process /proc memory snapshots inside the callback. Acquiring locks or
performing I/O on the main thread during active memory reclaim can block behind
reclaim-throttled background threads and cause Application Not Responding (ANR) errors.
Summary
Public methods | |
|---|---|
abstract
void
|
onOverBudget(long budget)
Called on the registered |
Public methods
onOverBudget
public abstract void onOverBudget (long budget)
Called on the registered Looper when the application or process exceeds its
budget.
Implementations should run on a background HandlerThread
Looper, remain fast, lock-free, and allocation-free, and avoid blocking I/O or
full-process /proc memory snapshots (use
MemoryBudgetManager.getProcessCurrentUsageBytes()
or
MemoryBudgetManager.getPackageCurrentUsageBytes()
instead when checking current usage).
| Parameters | |
|---|---|
budget |
long: budget (in bytes) that was exceeded. |