MemoryPressureMonitor

System memory pressure observer for Android.

Listens to system ComponentCallbacks2.onTrimMemory events and maintains a state indicating whether the device is under critical memory pressure.

Functions

Link copied to clipboard

Checks if the device is currently under critical memory pressure.

Link copied to clipboard
open override fun onConfigurationChanged(newConfig: Configuration)

Called by the OS on device configuration changes; not a memory signal, so a no-op here.

Link copied to clipboard
open override fun onLowMemory()

Called by the OS under severe memory pressure; always marks critical.

Link copied to clipboard
open override fun onTrimMemory(level: Int)

Called by the OS as memory pressure rises or falls; updates the critical flag accordingly.

Link copied to clipboard
fun register(context: Context)

Registers this monitor with the application Context.

Link copied to clipboard
fun unregister(context: Context)

Unregisters this monitor from the application Context.