简体   繁体   中英

Robolectric java heap size error

So I am running my tests using Robolectric 3.1.4. In another project I had no problems running all my test with robolectric, but right now I always get this error:

java.lang.OutOfMemoryError: Java heap space

When I remove some views of the activity, the problem stops...

Well, my question is: How can I increase the heap size in the project or how can I make robolectric consume less memory?

Any help is appreciated!

This kind of problem usually happens when you're displaying too many images on your activities. Probably using some ViewPager? If that's the case, you can read this , which explains how to use cache to store images and reduce memory consumption.

Another solution is increasing the heap size, by setting this on the AndroidManifest.xml: android:largeHeap=”true” .. But keep in mind that this is used mostly on apps that require a lot of memory like games, video processors, etc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM