android onLowMemory

来源:互联网 发布:大数据平台架构 编辑:程序博客网 时间:2024/05/21 20:23
ActivityThread.collectComponentCallbacksLocked 收集onLowMemory


ActivityThread.handleLowMemory
  ActivityThread.h.handleMessage (LOW_MEMORY)
    ActivityThread.scheduleLowMemory
      ActivityManagerService.performAppGcLocked
        ActivityManagerService.performAppGcsLocked
 ActivityManagerService.performAppGcsIfAppropriateLocked
   ActivityManagerService.mHandler.handleMessage (GC_BACKGROUND_PROCESSES_MSG)
     ActivityManagerService.scheduleAppGcsLocked

1, ActivityManagerService.appDiedLocked 
2, ActivityRecord.windowVisible
WindowManagerService.H.handleMessage (REPORT_APPLICATION_TOKEN_WINDOWS)

WindowManagerService.updateReportedVisibilityLocked

3, other ...


调用流程

com.david.bitmapapp.BitmapAppActivity.onLowMemory(BitmapAppActivity.java:66)
 android.app.ActivityThread.handleLowMemory(ActivityThread.java:4089)
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2119)
 android.os.Handler.dispatchMessage(Handler.java:99)
 android.os.Looper.loop(Looper.java:123)
 android.app.ActivityThread.main(ActivityThread.java:4627)
 java.lang.reflect.Method.invokeNative(Native Method)
 java.lang.reflect.Method.invoke(Method.java:521)
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
 dalvik.system.NativeStart.main(Native Method)

 

备注:onLowMemory是在background process等可结束进程都结束后,当前进程才调用的。

例子:http://download.csdn.net/download/imyfriend/4110687

log:

04-10 03:06:44.844: I/ActivityManager(59): Process android.process.acore (pid 151) has died.
04-10 03:06:45.284: I/ActivityManager(59): Process com.android.alarmclock (pid 157) has died.
04-10 03:06:45.384: I/ActivityManager(59): Process com.android.settings (pid 135) has died.
04-10 03:06:46.634: I/ActivityManager(59): Process com.android.mms (pid 206) has died.
04-10 03:06:47.144: I/ActivityManager(59): Process com.android.email (pid 222) has died.
04-10 03:06:48.254: I/ActivityManager(59): Process com.android.protips (pid 185) has died.
04-10 03:06:48.574: I/ActivityManager(59): Process com.android.music (pid 169) has died.
04-10 03:06:48.974: I/ActivityManager(59): Process com.android.quicksearchbox (pid 176) has died.
04-10 03:06:54.224: I/ActivityManager(59): Process android.process.media (pid 194) has died.
04-10 03:06:55.064: I/ActivityManager(59): Process com.android.defcontainer (pid 258) has died.
04-10 03:06:55.414: I/ActivityManager(59): Process com.svox.pico (pid 268) has died.
04-10 03:06:55.424: I/ActivityManager(59): Low Memory: No more background processes.
04-10 03:06:56.344: I/ActivityManager(59): Process com.android.launcher (pid 118) has died.
04-10 03:06:56.543: I/WindowManager(59): WIN DEATH: Window{45065120 com.android.launcher/com.android.launcher2.Launcher paused=false}
04-10 03:06:56.754: I/ActivityManager(59): Low Memory: No more background processes.
04-10 03:07:06.164: D/skia(112): purging 6K from font cache [1 entries]
04-10 03:07:06.794: D/dalvikvm(112): GC_EXPLICIT freed 9133 objects / 438256 bytes in 414ms
04-10 03:07:10.869: I/BitmapAppActivity(284): SecondActivity.onLowMemory
04-10 03:07:10.869: I/BitmapAppActivity(284): BitmapAppActivity.onLowMemory
04-10 03:07:10.874: I/BitmapAppActivity(284): BitmapApplication.onLowMemory
04-10 03:07:10.907: D/skia(284): purging 50K from font cache [6 entries]
04-10 03:07:11.096: D/dalvikvm(284): GC_EXPLICIT freed 2142 objects / 120200 bytes in 181ms
04-10 03:07:15.886: D/skia(59): purging 302K from font cache [26 entries]
04-10 03:07:16.025: D/dalvikvm(59): GC_EXPLICIT freed 19727 objects / 832480 bytes in 132ms


参考:http://www.apkbus.com/android-20374-1-1.html

原创粉丝点击