Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Aug 18, 2015 · 5 comments
Open

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 4 Jun 2015 at 1:18

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 4 Jun 2015 at 12:22

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 5 Jun 2015 at 1:08

@GoogleCodeExporter
Copy link
Author

Thanks for reporting this. 

Original comment by [email protected] on 5 Jun 2015 at 3:25

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

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 [email protected] on 5 Jun 2015 at 3:45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant