Språk

Activity.OnLowMemory Method

Definition

On Android 13 and earlier, notifies the activity that the system is running low on memory.

[Android.Runtime.Register("onLowMemory", "()V", "GetOnLowMemoryHandler")]
public virtual void OnLowMemory();
[<Android.Runtime.Register("onLowMemory", "()V", "GetOnLowMemoryHandler")>]
abstract member OnLowMemory : unit -> unit
override this.OnLowMemory : unit -> unit

Implements

Attributes

Remarks

On Android 13 and earlier, this is called when the overall system is running low on memory, and actively running processes should trim their memory usage. While the exact point at which this will be called is not defined, generally it will happen when all background process have been killed. That is, before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

Starting with Android 14 (API level 34), the system does not call this method. Use OnTrimMemory(TrimMemory) instead.

Android reference for android.app.Activity.onLowMemory.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to