The system raises the level of the process(es) hosting content providers you are using to the same level as yours; so if your app is in the foreground when this happens, it means that there is just so little memory available in the system that it can't even keep all of the foreground processes going, and aside from simply not using that provider there is little you can do. (You can be sure to not keep open access on providers, if you are keeping them open for a long time, so the system has some other process to kill that you don't need right then.)
If this is happening while you are in the background running a service... well, getting killed while in the background is something that will happen, and the more sessions you have with providers the more likely it is to happen since this causes more memory pressure. Again, only keep providers open while you need them, and accept you will have your service killed at some points, with or without it using providers. On 1.6 you can use "adb shell dumpsys activity" to see a list of all of the running processes, what level they are at, and why this is, which can help track down for example why a lot of processes may be in the foreground. This is the second to last pocess list, with the oom_adj levels. On Sun, Dec 6, 2009 at 9:58 AM, Daniel <[email protected]>wrote: > Some of my apps silently close on my G1 (Android 1.6) because some > Content Providers they use are hosted in processes that are killed due > to low memory. Is there anything to protect an app from silently > closing because a content provider it uses is shut down? Is there some > remote exception to give the app a change to continue its work with > less features (e.g. do not query dead content providers)? > Below is a trace that shows this situation. > > Quickdroid uses the BrowserProvider. But since the BrowserProvider and > its hosting Linux process died, Quickdroid is also killed silently. > That is a really bad user experience :-( > > I/ActivityManager( 75): Starting activity: Intent > { cmp=fm.last.android/.activity.Preferences } > I/ActivityManager( 75): Process fm.last.android:player (pid 17574) > has died. > I/ActivityManager( 75): Low Memory: No more background processes. > I/ActivityManager( 75): Displayed activity > fm.last.android/.activity.Preferences: 844 ms (total 844 ms) > D/dalvikvm(17546): GC freed 4991 objects / 247032 bytes in 155ms > I/ActivityManager( 75): Start proc fm.last.android:player for > service fm.last.android/.player.RadioPlayerService: pid=17676 > uid=10051 gids={3003, 1015} > I/fm.last.android.player(17676): Player service started > I/ActivityManager( 75): Stopping service: > fm.last.android/.player.RadioPlayerService > I/fm.last.android.player(17676): Player service shutting down > I/ActivityManager( 75): Start proc vu.de.urpool.quickdroid for > activity vu.de.urpool.quickdroid/.Quickdroid: pid=17683 uid=10030 gids= > {} > I/ActivityManager( 75): Process fm.last.android:player (pid 17676) > has died. > I/ActivityManager( 75): Low Memory: No more background processes. > I/ActivityThread(17683): Publishing provider quickdroid: > vu.de.urpool.quickdroid.apps.AppProvider > I/ActivityManager( 75): Start proc com.android.browser for content > provider com.android.browser/.BrowserProvider: pid=17696 uid=10022 > gids={3003} > I/ActivityThread(17696): Publishing provider browser: > com.android.browser.BrowserProvider > I/ActivityManager( 75): Displayed activity > vu.de.urpool.quickdroid/.Quickdroid: 2802 ms (total 2802 ms) > I/ActivityManager( 75): Process fm.last.android (pid 17546) has > died. > I/WindowManager( 75): WIN DEATH: Window{4397eb40 fm.last.android/ > fm.last.android.activity.Profile paused=false} > I/ActivityManager( 75): Low Memory: No more background processes. > I/ActivityThread(17683): Removing dead content provider: browser > I/ActivityManager( 75): Process com.android.browser (pid 17696) has > died. > I/ActivityManager( 75): Killing app vu.de.urpool.quickdroid (pid > 17683) because provider com.android.browser.BrowserProvider is in > dying process com.android.browser > I/Process ( 75): Sending signal. PID: 17683 SIG: 9 > I/WindowManager( 75): WIN DEATH: Window{43a0eff0 > vu.de.urpool.quickdroid/vu.de.urpool.quickdroid.Quickdroid > paused=false} > I/ActivityManager( 75): Low Memory: No more background processes. > I/ActivityManager( 75): Process vu.de.urpool.quickdroid (pid 17683) > has died. > W/UsageStats( 75): Unexpected resume of com.android.launcher while > already resumed in vu.de.urpool.quickdroid > I/ActivityManager( 75): Low Memory: No more background processes. > W/InputManagerService( 75): Got RemoteException sending setActive > (false) notification to pid 17683 uid 10030 > I/ActivityManager( 75): Starting activity: Intent > { act=android.intent.action.MAIN cat= > [android.intent.category.LAUNCHER] flg=0x10200000 > cmp=vu.de.urpool.quickdroid/.Quickdroid } > I/ActivityManager( 75): Start proc vu.de.urpool.quickdroid for > activity vu.de.urpool.quickdroid/.Quickdroid: pid=17708 uid=10030 gids= > {} > D/dalvikvm( 50): GC freed 269 objects / 10248 bytes in 174ms > D/dalvikvm( 50): GC freed 42 objects / 1816 bytes in 104ms > D/dalvikvm( 50): GC freed 2 objects / 56 bytes in 83ms > I/ActivityThread(17708): Publishing provider quickdroid: > vu.de.urpool.quickdroid.apps.AppProvider > I/ActivityManager( 75): Displayed activity > vu.de.urpool.quickdroid/.Quickdroid: 1399 ms (total 1399 ms) > I/ActivityManager( 75): Starting activity: Intent > { act=android.intent.action.MAIN cat= > [android.intent.category.LAUNCHER] flg=0x10000000 > cmp=com.android.term/.Term } > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

