Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 加载时内存溢出崩溃_Android_Performance_Android Memory - Fatal编程技术网

Android 加载时内存溢出崩溃

Android 加载时内存溢出崩溃,android,performance,android-memory,Android,Performance,Android Memory,我有一次车祸,我在谷歌Play上收到了以下报告 java.lang.OutOfMemoryError: [memory exhausted] at dalvik.system.NativeStart.main(Native Method) 正如你所看到的,没有太多的信息。有人问同样的问题,但我不相信忽视它的答案是可以接受的 堆栈跟踪中没有关于我的应用程序的任何内容,这表明是操作系统不允许应用程序启动。这意味着我们无能为力,但是,即使用户重新启动了设备,他们仍然无法打开应用程序。我的应用程序不大

我有一次车祸,我在谷歌Play上收到了以下报告

java.lang.OutOfMemoryError: [memory exhausted]
at dalvik.system.NativeStart.main(Native Method)
正如你所看到的,没有太多的信息。有人问同样的问题,但我不相信忽视它的答案是可以接受的

堆栈跟踪中没有关于我的应用程序的任何内容,这表明是操作系统不允许应用程序启动。这意味着我们无能为力,但是,即使用户重新启动了设备,他们仍然无法打开应用程序。我的应用程序不大:设备上有22.20MB

请参阅以下或崩溃报告统计信息


我能做些什么来纠正这一点,或者至少减少发生这种情况的可能性吗?

不知道这是不是一个正确的解决方案,但它解决了我的问题。java.lang.OutOfMemoryError的常见原因是缓存溢出。我所做的就是清除了启动程序活动上的应用程序缓存。因此,无论何时启动应用程序,它都会清除缓存

将此方法添加到启动程序活动的onCreate方法之外

//Following two methods are used to clear the Cache memory of this application
public static void deleteCache(Context context) {
    try {
        File dir = context.getCacheDir();
        if (dir != null && dir.isDirectory()) {
            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();
}

并称之为:;在onCreate内部。

您的应用程序在调试模式下工作正常吗?是的,它工作正常。我无法重现这个问题,以前从未见过。您可以试试这个。我希望这能有所帮助。你是想一次加载很多位图,比如一个数组还是一个大数组?没有关于你应用程序结构、清单、onStart内容等的信息。。。我们只能猜测。。。