我有应用程序,当我按下主页按钮并等待一段时间,尝试返回应用程序时,我正在强制关闭,我的应用程序显示废话。
我发现只有错误:
java.lang.OutOfMemoryError: (Heap Size=98304KB, Allocated=90124KB)
at android.database.CursorWindow.nativeGetString(Native Method)
at android.database.CursorWindow.getString(CursorWindow.java:492)
at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
at myapppackage.domain.Operator.buildFromCursor(Operator.java:39)
at myapppackage.adapter.CarouselAdapter.getMostCenterFavoriteOperatorId(CarouselAdapter.java:223)
at myapppackage.fragment.OperatorsFragment.onLoadFinished(OperatorsFragment.java:118)
at myapppackage.fragment.OperatorsFragment.onLoadFinished(OperatorsFragment.java:44)
at android.app.LoaderManagerImpl$LoaderInfo.callOnLoadFinished(LoaderManager.java:483)
at android.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManager.java:451)
at android.content.Loader.deliverResult(Loader.java:143)
at myapppackage.fragment.OperatorsFragment$DataLoader.deliverResult(OperatorsFragment.java:213)
at myapppackage.fragment.OperatorsFragment$DataLoader.deliverResult(OperatorsFragment.java:169)
at android.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:254)
at android.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:91)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:5751)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
at dalvik.system.NativeStart.main(Native Method)
如何防止这种情况发生?
编辑:
关于内存泄漏的发现非常有用:
http://www.youtube.com/watch?v=_CruQY55HOk&feature=share&list=PL4uOUQa48SihVk0Mh9-STLs8HnKuAgMD6
答案 0 :(得分:2)
检查您的家庭活动是否没有任何循环! 或者无法无限次创建对象
答案 1 :(得分:1)
很难说没有代码......这些链接可能有所帮助:
http://android-developers.blogspot.in/2009/01/avoiding-memory-leaks.html
http://ttlnews.blogspot.in/2010/01/attacking-memory-problems-on-android.html
答案 2 :(得分:0)
还要确保图像(如果使用任何图像)不高于所需的分辨率。由于非常大的图像或背景也会导致OOM异常。