Open chentangchun opened 6 years ago
我添加了下面的代码,后面好像又没有报此异常了: pdfView.useBestQuality(false); Constants.Cache.CACHE_SIZE = 40;’
@barteksc Current implementation of cache manager is not quite right, 'cause different devices can have different amount of free RAM at some moments. My suggestion is to implement CacheManager using LRUCache and avoid allocating memory for bitmaps. https://developer.android.com/topic/performance/graphics/manage-memory
@chentangchun 's comment (translated by Google)
I added the following code, and it seems that I have not reported this exception. pdfView.useBestQuality(false); Constants.Cache.CACHE_SIZE = 40;’
This fix worked for me on a Samsung Galaxy Tab A7 with 1.5Gb memory.
W/dalvikvm: threadid=31: thread exiting with uncaught exception (group=0x94cffb20) E/AndroidRuntime: FATAL EXCEPTION: PDF renderer Process: com.****, PID: 2195 java.lang.OutOfMemoryError at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:809) at android.graphics.Bitmap.createBitmap(Bitmap.java:786) at android.graphics.Bitmap.createBitmap(Bitmap.java:753) at com.github.barteksc.pdfviewer.RenderingHandler.proceed(RenderingHandler.java:102) at com.github.barteksc.pdfviewer.RenderingHandler.handleMessage(RenderingHandler.java:66) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.os.HandlerThread.run(HandlerThread.java:61)