public interface MemoryTrimmer
An interface for use memory usage aware apps that implement the
Application.ActivityLifecycleCallbacks.
Can be implemented by any long-existing class for being called by the activity lifecycle
callback methods Application.ActivityLifecycleCallbacks#onTrimMemory(int) and
Application.ActivityLifecycleCallbacks#onLowMemory().
| Modifier and Type | Method and Description |
|---|---|
void |
onForceTrim()
Strict release of all not strictly necessary memory resources.
|
void |
onTrim()
Relaxed release of memory
|
void onTrim()
Relaxed release of memory
This is the method that should be called from
Application.ActivityLifecycleCallbacks#onTrimMemory(int) on a level like
Application.ActivityLifecycleCallbacks#TRIM_MEMORY_BACKGROUND.
Though this is not mandatory, and this method can be run at any level, it is recommended
to have this method run at a lower level than the onForceTrim() method.
void onForceTrim()
Strict release of all not strictly necessary memory resources.
The call to this method should also ensure that all resources that would be freed by
onTrim() are definitely freed.
This is the method that should be called from
Application.ActivityLifecycleCallbacks#onLowMemory() or preferrably from
Application.ActivityLifecycleCallbacks#onTrimMemory(int) with the
Application.ActivityLifecycleCallbacks#TRIM_MEMORY_COMPLETE level.