Language

Service.OnTrimMemory(TrimMemory) Method

Definition

Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process.

[Android.Runtime.Register("onTrimMemory", "(I)V", "GetOnTrimMemory_IHandler")]
public virtual void OnTrimMemory(Android.Content.TrimMemory level);
[<Android.Runtime.Register("onTrimMemory", "(I)V", "GetOnTrimMemory_IHandler")>]
abstract member OnTrimMemory : Android.Content.TrimMemory -> unit
override this.OnTrimMemory : Android.Content.TrimMemory -> unit

Parameters

level
TrimMemory

int: The context of the trim, giving a hint of the amount of trimming the application may like to perform. Value is one of the following: Complete Moderate Background UiHidden RunningCritical RunningLow RunningModerate

Implements

Attributes

Remarks

Called when the operating system has determined that it is a good time for a process to trim unneeded memory from its process. You should never compare to exact values of the level, since new intermediate values may be added -- you will typically want to compare if the value is greater or equal to a level you are interested in. To retrieve the processes current trim level at any point, you can use ActivityManager.getMyMemoryState(RunningAppProcessInfo).

Android reference for android.app.Service.onTrimMemory.

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