How much memory should my application save after closing

As soon as I open the application, it saves about 7 MB (via the Android Studio Memory Monitor) and during its use (filling the View list with custom items) it appears up to about 9 MB: 12 ​​MB

After I close the application and use the “Initiate GC” from Android Studio, it will drop to about 8.3 MB.

So, does this mean / mean that I have a memory leak?

Should it go back to 7MB from the start?

or shouldn't be 0MB as my application closes?

+4
source share
1 answer

If you are looking for a cache to delete your own application, just delete the cache directory and everyone has done it!

public static void deleteCache(Context context) {
    try {
        File dir = context.getCacheDir();
        deleteDir(dir);
    } catch (Exception e) {}
}

public static boolean deleteDir(File dir) {
    if (dir != null && dir.isDirectory()) {
        String[] children = dir.list();
        for (int i = 0; i < children.length; i++) {
            boolean success = deleteDir(new File(dir, children[i]));
            if (!success) {
                return false;
            }
        }
        return dir.delete();
    }
    else if(dir!= null && dir.isFile())
        return dir.delete();
    else {
        return false;
    }
}

,

<uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>

: Clear Cache Android

-1

All Articles