我有应用程序,当我按下主页按钮并等待一段时间,试图返回应用程序时,我正在强制关闭并且我的应用程序显示废话。
我发现的唯一错误:
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