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
Out of memory error when using View Pager to load images. #56
Comments
can you turn logging on in the library (see Constants.java) and attach a full log? |
How to assign logging true within code? thanks |
going to Constants.java and setting to true this line: |
Closing since it is stale. I don't thikn you should construct the view in instantiateItem like that. Override getItem to return a Fragment, and then override getView to return a view. Returning a view in instantiateItem means that references may be held keeping the images in memory. |
Hello, i'm rather new at Android development. I'm using a view pager to load in an array of Urls for displaying. I am getting an out of memory error when swiping through the images. I do not notice any patterns when this happens, But I do notice it if I swipe fast. This is my first time implementing a View Pager so I may be missing something important. Has anyone ever used UrlImageViewHelper with a view pager? I will paste the code I have to see if we can figure out the root of the problem. I feel like the most important piece I am missing is with the PagerAdapter. Here is the code:
private class ImagePagerAdapter extends PagerAdapter {
Here is the output from LogCat:
04-01 16:37:30.212: E/AndroidRuntime(18279): FATAL EXCEPTION: AsyncTask #3
04-01 16:37:30.212: E/AndroidRuntime(18279): java.lang.RuntimeException: An error occured while executing doInBackground()
04-01 16:37:30.212: E/AndroidRuntime(18279): at android.os.AsyncTask$3.done(AsyncTask.java:200)
04-01 16:37:30.212: E/AndroidRuntime(18279): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
04-01 16:37:30.212: E/AndroidRuntime(18279): at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
04-01 16:37:30.212: E/AndroidRuntime(18279): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
04-01 16:37:30.212: E/AndroidRuntime(18279): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
04-01 16:37:30.212: E/AndroidRuntime(18279): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
04-01 16:37:30.212: E/AndroidRuntime(18279): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
04-01 16:37:30.212: E/AndroidRuntime(18279): at java.lang.Thread.run(Thread.java:1027)
04-01 16:37:30.212: E/AndroidRuntime(18279): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget(Heap Size=7111KB, Allocated=3616KB, Bitmap Size=25807KB)
04-01 16:37:30.212: E/AndroidRuntime(18279): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-01 16:37:30.212: E/AndroidRuntime(18279): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:694)
04-01 16:37:30.212: E/AndroidRuntime(18279): at com.koushikdutta.urlimageviewhelper.UrlImageViewHelper.loadBitmapFromStream(UrlImageViewHelper.java:117)
04-01 16:37:30.212: E/AndroidRuntime(18279): at com.koushikdutta.urlimageviewhelper.UrlImageViewHelper.access$3(UrlImageViewHelper.java:94)
04-01 16:37:30.212: E/AndroidRuntime(18279): at com.koushikdutta.urlimageviewhelper.UrlImageViewHelper$1.onDownloadComplete(UrlImageViewHelper.java:589)
04-01 16:37:30.212: E/AndroidRuntime(18279): at com.koushikdutta.urlimageviewhelper.UrlImageViewHelper$3.doInBackground(UrlImageViewHelper.java:655)
04-01 16:37:30.212: E/AndroidRuntime(18279): at com.koushikdutta.urlimageviewhelper.UrlImageViewHelper$3.doInBackground(UrlImageViewHelper.java:1)
04-01 16:37:30.212: E/AndroidRuntime(18279): at android.os.AsyncTask$2.call(AsyncTask.java:185)
04-01 16:37:30.212: E/AndroidRuntime(18279): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
04-01 16:37:30.212: E/AndroidRuntime(18279): ... 4 more
Thank you so much for providing me with your helper class :) (sorry for a big wall of mess, hopefully it's not too painful)
The text was updated successfully, but these errors were encountered: