我正在尝试构建一个实现自定义viewpager的android应用程序,但问题是内存溢出。
这是我的logcat
06-03 22:04:53.837: I/dalvikvm-heap(21165): Clamp target GC heap from 102.937MB to 96.000MB
06-03 22:04:53.838: D/dalvikvm(21165): GC_FOR_ALLOC freed 175K, 2% free 97183K/98188K, paused 31ms, total 31ms
06-03 22:04:53.839: I/dalvikvm-heap(21165): Forcing collection of SoftReferences for 640016-byte allocation
06-03 22:04:53.877: I/dalvikvm-heap(21165): Clamp target GC heap from 102.907MB to 96.000MB
06-03 22:04:53.883: D/dalvikvm(21165): GC_BEFORE_OOM freed 95K, 2% free 97087K/98188K, paused 43ms, total 43ms
06-03 22:04:53.883: E/dalvikvm-heap(21165): Out of memory on a 640016-byte allocation.
06-03 22:04:53.883: I/dalvikvm(21165): "main" prio=5 tid=1 RUNNABLE
06-03 22:04:53.883: I/dalvikvm(21165): | group="main" sCount=0 dsCount=0 obj=0x416efe40 self=0x41610850
06-03 22:04:53.883: I/dalvikvm(21165): | sysTid=21165 nice=0 sched=0/0 cgrp=apps handle=1074737492
06-03 22:04:53.884: I/dalvikvm(21165): | state=R schedstat=( 0 0 0 ) utm=1845 stm=250 core=1
06-03 22:04:53.884: I/dalvikvm(21165): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-03 22:04:53.884: I/dalvikvm(21165): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
06-03 22:04:53.884: I/dalvikvm(21165): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
06-03 22:04:53.884: I/dalvikvm(21165): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:445)
06-03 22:04:53.884: I/dalvikvm(21165): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:475)
06-03 22:04:53.884: I/dalvikvm(21165): at com.facebook.widget.ProfilePictureView.setBlankProfilePicture(ProfilePictureView.java:409)
06-03 22:04:53.884: I/dalvikvm(21165): at com.facebook.widget.ProfilePictureView.setProfileId(ProfilePictureView.java:222)
06-03 22:04:53.885: I/dalvikvm(21165): at com.test.balls.ShowDetailsFragment.updateViews(ShowDetailsFragment.java:213)
06-03 22:04:53.885: I/dalvikvm(21165): at com.test.balls.ShowDetailsFragment.onActivityCreated(ShowDetailsFragment.java:107)
06-03 22:04:53.885: I/dalvikvm(21165): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:892)
06-03 22:04:53.885: I/dalvikvm(21165): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
06-03 22:04:53.885: I/dalvikvm(21165): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
06-03 22:04:53.885: I/dalvikvm(21165): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
06-03 22:04:53.885: I/dalvikvm(21165): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
06-03 22:04:53.886: I/dalvikvm(21165): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
06-03 22:04:53.886: I/dalvikvm(21165): at android.support.v4.view.ViewPager.populate(ViewPager.java:895)
06-03 22:04:53.886: I/dalvikvm(21165): at android.support.v4.view.ViewPager.populate(ViewPager.java:772)
06-03 22:04:53.886: I/dalvikvm(21165): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1234)
06-03 22:04:53.886: I/dalvikvm(21165): at android.view.View.measure(View.java:16537)
06-03 22:04:53.886: I/dalvikvm(21165): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
06-03 22:04:53.886: I/dalvikvm(21165): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
06-03 22:04:53.886: I/dalvikvm(21165): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
06-03 22:04:53.887: I/dalvikvm(21165): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
06-03 22:04:53.887: I/dalvikvm(21165): at android.view.View.measure(View.java:16537)
06-03 22:04:53.887: I/dalvikvm(21165): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
06-03 22:04:53.887: I/dalvikvm(21165): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
06-03 22:04:53.887: I/dalvikvm(21165): at android.view.View.measure(View.java:16537)
06-03 22:04:53.887: I/dalvikvm(21165): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
06-03 22:04:53.887: I/dalvikvm(21165): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
06-03 22:04:53.887: I/dalvikvm(21165): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
06-03 22:04:53.888: I/dalvikvm(21165): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
06-03 22:04:53.888: I/dalvikvm(21165): at android.view.View.measure(View.java:16537)
06-03 22:04:53.888: I/dalvikvm(21165): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
06-03 22:04:53.888: I/dalvikvm(21165): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
06-03 22:04:53.888: I/dalvikvm(21165): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
06-03 22:04:53.888: I/dalvikvm(21165): at android.view.View.measure(View.java:16537)
06-03 22:04:53.888: I/dalvikvm(21165): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1947)
06-03 22:04:53.888: I/dalvikvm(21165): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1137)
06-03 22:04:53.889: I/dalvikvm(21165): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1326)
06-03 22:04:53.889: I/dalvikvm(21165): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1024)
06-03 22:04:53.889: I/dalvikvm(21165): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5796)
06-03 22:04:53.889: I/dalvikvm(21165): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
06-03 22:04:53.889: I/dalvikvm(21165): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
06-03 22:04:53.889: I/dalvikvm(21165): at android.view.Choreographer.doFrame(Choreographer.java:544)
06-03 22:04:53.889: I/dalvikvm(21165): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
06-03 22:04:53.889: I/dalvikvm(21165): at android.os.Handler.handleCallback(Handler.java:733)
06-03 22:04:53.890: I/dalvikvm(21165): at android.os.Handler.dispatchMessage(Handler.java:95)
06-03 22:04:53.890: I/dalvikvm(21165): at android.os.Looper.loop(Looper.java:136)
06-03 22:04:53.890: I/dalvikvm(21165): at android.app.ActivityThread.main(ActivityThread.java:5102)
06-03 22:04:53.890: I/dalvikvm(21165): at java.lang.reflect.Method.invokeNative(Native Method)
06-03 22:04:53.890: I/dalvikvm(21165): at java.lang.reflect.Method.invoke(Method.java:515)
06-03 22:04:53.890: I/dalvikvm(21165): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
06-03 22:04:53.890: I/dalvikvm(21165): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
06-03 22:04:53.890: I/dalvikvm(21165): at dalvik.system.NativeStart.main(Native Method)
06-03 22:04:53.891: D/skia(21165): --- allocation failed for scaled bitmap
06-03 22:04:53.893: W/SQLiteConnectionPool(21165): A SQLiteConnection object for database '/data/data/com.test.balls/databases/databaseplayers' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
06-03 22:04:53.896: W/SQLiteConnectionPool(21165): A SQLiteConnection object for database '/data/data/com.test.balls/databases/databaseplayers' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
06-03 22:04:53.898: W/SQLiteConnectionPool(21165): A SQLiteConnection object for database '/data/data/com.test.balls/databases/databaseplayers' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
我在viewpager中只实现了3个片段,但应用程序仍然崩溃。 请建议我一种方法或优化技术来避免这个问题