Why ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL when the available memory is high?

36 views Asked by At

An app frequently gets ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL when the available memory is high. The following was the snapshot of the memory situation when this ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL happened:

Available memory (MB): 3041
Total memory (MB): 3926

The above numbers are obtained as follows:

ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
ActivityManager activityManager = (ActivityManager) activity.getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
lAvailableMemoryMB = mi.availMem / 0x100000L;
lTotalMemoryMB = mi.totalMem / 0x100000L;

I know the official document warns about availMem: "This number should not be considered absolute: due to the nature of the kernel, a significant portion of this memory is actually in use and needed for the overall system to run well". However, available memory is over 3GB when TRIM_MEMORY_RUNNING_CRITICAL happens. Could anyone shed some light on this?

0

There are 0 answers