我有一个应用,其第一页只是带有加载符号的图像。在测试应用程序时,从来没有我在启动应用程序后单击主页按钮然后再次启动应用程序并以非常快的速率重复此操作我得到以下运行时异常:
08-15 05:47:53.555: INFO/ActivityManager(1146): Config changed: { scale=1.0 imsi=0/0 loc=en_IN touch=3 keys=1/1/2 nav=1/1 orien=2 layout=34}
08-15 05:47:53.655: WARN/InputManagerService(1146): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@45cc4df8
08-15 05:47:53.655: INFO/TouchPal(1248): density = 1.5
08-15 05:47:53.655: INFO/TouchPal(1248): scaledDensity = 1.5
08-15 05:47:53.655: INFO/TouchPal(1248): widthPixels = 854
08-15 05:47:53.655: INFO/TouchPal(1248): heightPixels = 480
08-15 05:47:53.655: INFO/TouchPal(1248): xdpi = 160.42105
08-15 05:47:53.655: INFO/TouchPal(1248): ydpi = 159.49706
08-15 05:47:53.655: INFO/TouchPal(1248): fontScale = 1.0
08-15 05:47:53.655: INFO/TouchPal(1248): hardKeyboardHidden = 2
08-15 05:47:53.655: INFO/TouchPal(1248): keyboard = 1
08-15 05:47:53.665: INFO/TouchPal(1248): keyboardHidden = 1
08-15 05:47:53.665: INFO/TouchPal(1248): navigation = 1
08-15 05:47:53.665: INFO/TouchPal(1248): orientation = 2
08-15 05:47:53.665: INFO/TouchPal(1248): touchscreen = 3
08-15 05:47:53.665: DEBUG/CompSplashWebViewClient(2528): onPageFinsihed/ For id: -1
08-15 05:47:53.665: DEBUG/CompSplashWebViewClient(2528): onPageFinsihed/ MAIN SCREEN URL HAS BEEN CACHED
08-15 05:47:53.665: DEBUG/FlipperController(2528): handleAction/ action : LOAD_MAIN_SCREEN
08-15 05:47:53.665: INFO/ActivityManager(1146): Starting activity: Intent { cmp=com.activities/.FlipperActivity }
08-15 05:47:53.665: INFO/TouchPal(1248): locale = English (India)
08-15 05:47:53.685: DEBUG/SplashScreenActivity(2528): onPause of BaseActivity
08-15 05:47:53.705: DEBUG/SplashScreenActivity(2528): Alarm Service Started
08-15 05:47:53.715: ERROR/TimeoutService(2528): onDestroy
08-15 05:47:53.745: DEBUG/FlipperActivity(2528): onCreate
这一个:
08-15 05:47:53.925: ERROR/dalvikvm-heap(2528): Heap Massage needed (1728000-byte external allocation too big)
08-15 05:47:53.925: ERROR/dalvikvm-heap(2528): -->Full GC (don't collect SoftReferences)
08-15 05:47:53.985: DEBUG/dalvikvm(2528): GC freed 11520 objects / 655400 bytes in 59ms
08-15 05:47:53.985: DEBUG/dalvikvm(2528): threadid=207 wakeup: interrupted
08-15 05:47:53.985: ERROR/dalvikvm-heap(2528): -->Full GC (collect SoftReferences)
08-15 05:47:54.045: DEBUG/dalvikvm(2528): GC freed 453 objects / 210240 bytes in 53ms
这是什么意思????
08-15 05:47:54.045: ERROR/dalvikvm-heap(2528): -->Heap Massage was unsuccessful for 1728000-bytes!
08-15 05:47:54.045: ERROR/dalvikvm-heap(2528): -->Heap Massage has failed...
08-15 05:47:54.045: DEBUG/AndroidRuntime(2528): Shutting down VM
08-15 05:47:54.045: WARN/dalvikvm(2528): threadid=3: thread exiting with uncaught exception (group=0x40023160)
08-15 05:47:54.045: ERROR/ACRA(2528): ACRA caught a RuntimeException exception for com.activities. Building report.
08-15 05:47:54.055: INFO/NotificationService(1146): enqueueToast pkg=com.activities callback=android.app.ITransientNotification$Stub$Proxy@45d31820 duration=1
08-15 05:47:54.075: DEBUG/ACRA(2528): Retrieve application default SharedPreferences.
08-15 05:47:54.095: INFO/global(2528): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
08-15 05:47:54.215: INFO/ACRA(2528): READ_LOGS not allowed. ACRA will not include LogCat and DropBox data.
08-15 05:47:54.565: DEBUG/dalvikvm(1146): GC freed 3519 objects / 195568 bytes in 93ms
08-15 05:47:54.745: DEBUG/dalvikvm(2528): GC freed 8487 objects / 518184 bytes in 65ms
08-15 05:47:54.985: DEBUG/dalvikvm(1146): GC freed 2087 objects / 106048 bytes in 92ms
08-15 05:47:55.235: DEBUG/dalvikvm(2528): GC freed 3220 objects / 159000 bytes in 66ms
08-15 05:47:55.375: DEBUG/dalvikvm(1146): GC freed 3682 objects / 155808 bytes in 93ms
08-15 05:47:55.425: DEBUG/ACRA(2528): Writing crash report file.
08-15 05:47:55.475: DEBUG/ACRA(2528): Mark all pending reports as approved.
08-15 05:47:55.475: DEBUG/ACRA(2528): Looking for error files in /data/data/com.activities/files
08-15 05:47:55.485: VERBOSE/ACRA(2528): About to start ReportSenderWorker from #handleException
08-15 05:47:55.485: DEBUG/ACRA(2528): Add user comment to null
08-15 05:47:55.485: DEBUG/ACRA(2528): #checkAndSendReports - start
08-15 05:47:55.485: DEBUG/ACRA(2528): Looking for error files in /data/data/com.activities/files
08-15 05:47:55.485: INFO/ACRA(2528): Sending file 1313387275000-approved.stacktrace
08-15 05:47:55.485: INFO/global(2528): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
08-15 05:47:55.485: INFO/global(2528): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
08-15 05:47:55.535: DEBUG/ACRA(2528): Sending report 910c5203-3c48-4588-beae-73b126229487
08-15 05:47:55.535: DEBUG/ACRA(2528): Connect to https://spreadsheets.google.com/formResponse?formkey=**********
08-15 05:47:55.615: DEBUG/ACRA(2528): Setting httpPost headers
08-15 05:47:55.615: DEBUG/ACRA(2528): Sending request to https://spreadsheets.google.com/formResponse?****************
08-15 05:47:55.885: DEBUG/dalvikvm(1146): GC freed 2850 objects / 117392 bytes in 82ms
08-15 05:47:58.615: DEBUG/ACRA(2528): #checkAndSendReports - finish
此例外的含义是什么?
08-15 05:47:59.495: ERROR/ACRA(2528): Idol 2011 fatal error : Unable to start activity ComponentInfo{com.activities/com.activities.FlipperActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
08-15 05:47:59.495: ERROR/ACRA(2528): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.activities/com.activities.FlipperActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
08-15 05:47:59.495: ERROR/ACRA(2528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.os.Looper.loop(Looper.java:123)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.app.ActivityThread.main(ActivityThread.java:4370)
08-15 05:47:59.495: ERROR/ACRA(2528): at java.lang.reflect.Method.invokeNative(Native Method)
08-15 05:47:59.495: ERROR/ACRA(2528): at java.lang.reflect.Method.invoke(Method.java:521)
08-15 05:47:59.495: ERROR/ACRA(2528): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-15 05:47:59.495: ERROR/ACRA(2528): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-15 05:47:59.495: ERROR/ACRA(2528): at dalvik.system.NativeStart.main(Native Method)
08-15 05:47:59.495: ERROR/ACRA(2528): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
08-15 05:47:59.495: ERROR/ACRA(2528): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
08-15 05:47:59.495: ERROR/ACRA(2528): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-15 05:47:59.495: ERROR/ACRA(2528): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.app.Activity.setContentView(Activity.java:1625)
08-15 05:47:59.495: ERROR/ACRA(2528): at com.activities.FlipperActivity.onCreate(FlipperActivity.java:123)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
08-15 05:47:59.495: ERROR/ACRA(2528): ... 11 more
08-15 05:47:59.495: ERROR/ACRA(2528): Caused by: java.lang.reflect.InvocationTargetException
08-15 05:47:59.495: ERROR/ACRA(2528): at android.widget.RelativeLayout.<init>(RelativeLayout.java:171)
08-15 05:47:59.495: ERROR/ACRA(2528): at java.lang.reflect.Constructor.constructNative(Native Method)
08-15 05:47:59.495: ERROR/ACRA(2528): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
08-15 05:47:59.495: ERROR/ACRA(2528): ... 21 more
08-15 05:47:59.495: ERROR/ACRA(2528): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-15 05:47:59.495: ERROR/ACRA(2528): at android.graphics.Bitmap.nativeCreate(Native Method)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:715)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.content.res.Resources.loadDrawable(Resources.java:1705)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.view.View.<init>(View.java:1873)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.view.View.<init>(View.java:1822)
08-15 05:47:59.495: ERROR/ACRA(2528): at android.view.ViewGroup.<init>(ViewGroup.java:307)
08-15 05:47:59.495: ERROR/ACRA(2528): ... 25 more
08-15 05:47:59.535: INFO/Process(2528): Sending signal. PID: 2528 SIG: 9
08-15 05:47:59.595: INFO/ActivityManager(1146): Process com.activities (pid 2528) has died.
08-15 05:47:59.595: WARN/ActivityManager(1146): Scheduling restart of crashed service com.activities/com.service.TimeoutService in 5000ms
08-15 05:47:59.595: INFO/WindowManager(1146): Setting rotation to 0, animFlags=0
08-15 05:47:59.615: DEBUG/ViewFlipper(1294): updateRunning() mVisible=false, mStarted=true, mUserPresent=true, mRunning=false
08-15 05:47:59.635: WARN/WindowManager(1146): Rebuild removed 4 windows but added 3
08-15 05:47:59.665: INFO/WindowManager(1146): WIN DEATH: Window{45c599a8 com.activities/com.activities.SplashScreenActivity paused=false}
08-15 05:47:59.705: INFO/ActivityManager(1146): Config changed: { scale=1.0 imsi=0/0 loc=en_IN touch=3 keys=1/1/2 nav=1/1 orien=1 layout=34}
08-15 05:47:59.705: INFO/TouchPal(1248): density = 1.5
08-15 05:47:59.705: INFO/TouchPal(1248): scaledDensity = 1.5
08-15 05:47:59.705: INFO/TouchPal(1248): widthPixels = 480
08-15 05:47:59.705: INFO/TouchPal(1248): heightPixels = 854
08-15 05:47:59.705: INFO/TouchPal(1248): xdpi = 160.42105
08-15 05:47:59.705: INFO/TouchPal(1248): ydpi = 159.49706
08-15 05:47:59.705: INFO/TouchPal(1248): fontScale = 1.0
08-15 05:47:59.705: INFO/TouchPal(1248): hardKeyboardHidden = 2
08-15 05:47:59.715: INFO/TouchPal(1248): keyboard = 1
08-15 05:47:59.715: INFO/TouchPal(1248): keyboardHidden = 1
08-15 05:47:59.715: INFO/TouchPal(1248): navigation = 1
08-15 05:47:59.715: INFO/TouchPal(1248): orientation = 1
08-15 05:47:59.715: INFO/TouchPal(1248): touchscreen = 3
08-15 05:47:59.715: INFO/TouchPal(1248): locale = English (India)
08-15 05:47:59.885: INFO/UsageStats(1146): Unexpected resume of com.android.launcher while already
任何人都可以向我解释这里发生了什么吗? 对我来说奇怪的是,这项活动大部分时间都有效 如果它在上面的内存不足错误中崩溃的话。
答案 0 :(得分:0)
当暂停活动时,它不会释放用于加载的图像的位图,因此当重新加载时会消耗越来越多的内存,直到你的应用耗尽Android提供给它的内存(而你得到内存不足的例外)。
在活动的pause
方法中,请确保在加载图片时在正在创建的位图上调用Bitmap.recycle
。您可能需要使用生命周期方法并找出最佳释放/释放图像加载时分配的内存的位置,但这应该可以解决内存不足错误。