Compartilhar via


IComponentCallbacks2.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:Android.Content.IComponentCallbacks2Invoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public void OnTrimMemory (Android.Content.TrimMemory level);
[<Android.Runtime.Register("onTrimMemory", "(I)V", "GetOnTrimMemory_IHandler:Android.Content.IComponentCallbacks2Invoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member OnTrimMemory : Android.Content.TrimMemory -> unit

Parameters

level
TrimMemory

The context of the trim, giving a hint of the amount of trimming the application may like to perform.

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. This will happen for example when it goes in the background and there is not enough memory to keep as many background processes running as desired. 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 android.app.ActivityManager#getMyMemoryState ActivityManager.getMyMemoryState(RunningAppProcessInfo).

Java documentation for android.content.ComponentCallbacks2.onTrimMemory(int).

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