Skip to content Skip to sidebar Skip to footer

Large Images In Webview Cause Out Of Memory

I have activity that parses XML feed (with news) and loads parsed data (text and image url) in WebView's, which are inside gallery widget. Something like this: mimeType = 'text/ht

Solution 1:

Actually, you don't have so many choices. Freeing memory doesn't help as your images are still allocated in memory, and the images are too big to fit.

The only workable way is to reduce their size, either at the source (this way you have nothing to do programmatically) or at download time, before you display them (you save them scaled down to the SD and you display these local copies instead of the source images).

This depends of whether you have to use the full-scale images at some point. If not, there's absolutely no point in keeping them so large.

Solution 2:

Anyway, the problem was not in webview large images.

I downscaled app and apparently the problem was in my gallery widget design. To be more specific in graphical interface elements that surrounds it. Even with empty gallery after couple orientation changes I got oom.

And I found the reason to it only today. I used /drawables/ folder which downscales all images to mdpi. And all phones I tested it on was hdpi. Apparently android uses some maybe no so efficient scaling method, and it's leaking somewhere there.

I moved all my drawables to hdpi and mdpi folders and crashes magically stopped.

So, conclusion - avoid using /drawables/ folder.

Post a Comment for "Large Images In Webview Cause Out Of Memory"