user3051760
user3051760

Reputation:

How to clear inactive memory in Android programmatically?

How to free inactive memory in Android? I have seen some applications that claim to free RAM programmatically. After having studied them I found they free inactive memory of the device. Are there any APIs to do this?

Upvotes: 15

Views: 20832

Answers (2)

Andrii Bas
Andrii Bas

Reputation: 623

check this link

main code from it :

public void freeMemory(){       
    System.runFinalization();
    Runtime.getRuntime().gc();
    System.gc();
}

Upvotes: 24

suresh n
suresh n

Reputation: 345

call the garbage collector to free memory , best place to call it is onDestroy()

eg :

@Override
protected void onDestroy() {

    System.gc();

    super.onDestroy();
}

Upvotes: 6

Related Questions