act262 / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

java.lang.OutOfMemoryError occuring on hi-res screenshots #680

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Use emulator with high resolution like Nexus 10 2560x1600
2.Take 16+ screenshots in a session. Error happens sporadically

What is the expected output? What do you see instead?

Should save the screenshot to storage instead fatally throws an 
OutOfMemoryError with message like "Failed to allocated XX bytes with XX bytes 
remaining and XMB until 0". My JVM most certainly does have a high enough 
maximum and oddly enough I've gotten the error for smaller file sizes when 
using 1920x1080 resolution emulators. 

What version of the product are you using? On what operating system?
5.4.1

Please provide any additional information below.

Original issue reported on code.google.com by cam9...@gmail.com on 4 Jun 2015 at 1:18

GoogleCodeExporter commented 9 years ago
java.lang.OutOfMemoryError: Failed to allocate a 16384012 byte allocation with 
15854054 free bytes and 15MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.Bitmap.nativeCopy(Native Method)
at android.graphics.Bitmap.copy(Bitmap.java:557)
at com.robotium.solo.ScreenshotTaker.getBitmapOfView(ScreenshotTaker.java:246)
at com.robotium.solo.ScreenshotTaker.access$500(ScreenshotTaker.java:36)
at 
com.robotium.solo.ScreenshotTaker$ScreenshotRunnable.run(ScreenshotTaker.java:37
4)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Original comment by cam9...@gmail.com on 4 Jun 2015 at 12:22

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Discussions on similar topics that may be relevant
http://stackoverflow.com/questions/3117429/garbage-collector-in-android
http://developer.android.com/training/displaying-bitmaps/index.html

Original comment by cam9...@gmail.com on 5 Jun 2015 at 1:08

GoogleCodeExporter commented 9 years ago
Thanks for reporting this. 

Original comment by renasr...@gmail.com on 5 Jun 2015 at 3:25

GoogleCodeExporter commented 9 years ago
So it's possible that I may have been naturally hitting my JVM ceiling since 
adding "android largeHeap="true"" to my manifest prevented the error. However 
after looking at the source there may be some optimizations possible in the 
screenshot process. 

Also have you considered allowing the bitmap configuration to be set in the 
takeScreenshot() method? RGB_565, for example, could reduce memory usage

Original comment by cam9...@gmail.com on 5 Jun 2015 at 3:45