No low memory resolver

Context

Implementation

Affects

Memory Efficiency,Stability,User Experience

Problem

Mobile systems usually have little RAM and no SWAP space to free some memory.
Android provides a mechanism to help the system manage memory. The overrideable method Activity.onLowMemory() is called when all background process have been killed. That is, before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

This method should clean caches or unnecessary resources. If this method is not implemented this is considered a smell, due to the fact that it can cause abnormal programm termination.

Refactorings

Override onLowMemory Efficiency()

Resolves

Memory Efficiency,Stability,User Experience

Affects

Solution

class MyActivity extends Activity {

    ...

    @Override
    public void onLowMemory Efficiency() {
        // clean caches and unnecessary ressources
    }
}

Links

Related