Bug 693546

Summary: Bitmaps are not recycled in Android, leading to OutOfMemory errors
Product: MuPDF Reporter: André Ferreira <deleety>
Component: mupdfAssignee: Tor Andersson <tor.andersson>
Status: RESOLVED FIXED    
Severity: major CC: deleety, jackie.rosen, robin.watts, saimaram7
Priority: P4    
Version: master   
Hardware: Android Phone   
OS: Android   
Customer: Word Size: ---
Attachments: Source patch

Description André Ferreira 2013-01-10 19:03:46 UTC
Created attachment 9204 [details]
Source patch

Observable by zooming in and out of a PDF repeatedly.

The library will allocate bitmaps for each zoom operation which will not be released by the system as there is no explicit call to Bitmap.recycle().

This patch resolves the issue.
Comment 1 Robin Watts 2013-01-11 15:43:33 UTC
Fixed in:

commit f30db116a89652de0da03e27513753f0e432fd1a
Author: Robin Watts <robin.watts@artifex.com>
Date:   Thu Jan 10 20:19:20 2013 +0000

    Bug 693546: Improve Bitmap recycling in Android app.

    Thanks to Andre Ferreira for bringing this up and submitting a
    patch. (Andre should have &eacute, but this upsets git/my editor, sorry!)

    Change BitmapHolder handling so that we explicitly recycle bitmaps.
    Old versions of Android need this to avoid bitmaps 'sticking' in
    memory, and it doesn't hurt on new versions.

    Also, explicitly empty the bitmap holder before creating a new
    bitmap. This avoids us holding more than one copy of the (potentially
    large) bitmaps.

Many thanks!