Android WebView Out of memory allocation

孤街醉人 提交于 2019-12-25 04:06:30

问题


I have a WebView that shows a bitmap from uri. It works well the first 7 or 8 times it is loaded but then when loading it i get this error. Need help please.

01-27 18:44:27.155  30480-30480/? E/dalvikvm-heap﹕ Out of memory on a 631816-byte allocation.
01-27 18:44:30.579  15859-15859/? E/MtpService﹕ In MTPAPP onReceive:android.intent.action.BATTERY_CHANGED
01-27 18:44:30.579  15859-15859/? E/MtpService﹕ battPlugged Type : 2
01-27 18:44:34.362    1704-8058/? E/Dumper﹕ 3: 48387128549: User action: dump logging  circular buffer and context
01-27 18:44:34.362    1705-2000/? E/Dumper﹕ 3: 48387128549: User action: dump logging circular buffer and context
01-27 18:44:34.362    1704-8058/? E/Dumper﹕ 4: 48387128579: Triggering circular buffer dump in /data/ste-debug
01-27 18:44:34.362    1705-2000/? E/Dumper﹕ 4: 48387128579: Triggering circular buffer dump in /data/ste-debug
01-27 18:44:35.023  30960-30971/? E/SQLiteLog﹕ (1) duplicate column name: EVENT_TYPE
01-27 18:44:35.123    2296-2296/? E/Launcher﹕ Error finding setting, default accessibility to not found: accessibility_enabled

回答1:


Are you recycling your bitmaps? Could you reduce the size of the images?

Please look at these links:

Strange out of memory issue while loading an image to a Bitmap object

Large images in WebView cause Out Of Memory

webview capturing causes out of memory exception




回答2:


Have you considered implementing onLowMemory() and using freeMemory on the WebView? You could also use clearCache. Another consideration would be to change the cache mode.



来源:https://stackoverflow.com/questions/21388009/android-webview-out-of-memory-allocation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!