3

Hello I am using MuPdf library in my project to view documents. The problem is that when you open 3-7 documents in a activity 11 inches on the tablet, i get memory overflow. When you load a new document, all references to the previous document are destroyed, but the image of the document from memory are not removed. objects are created in the memory image of 10-12 megabytes. on tablet the size of 7 inches this problem does not arise.

Maybe someone encountered this problem?

alezhka
  • 738
  • 2
  • 12
  • 29
  • I'm also looking for a solution. I received a outofmemory error when i open and close in different page the pdf activity. If mupdf render in low quality there is no problem, but when it render in HQ (so mainly in portrait mode at full screen page in a tablet 10.1) it goes overvflow – markov00 May 13 '12 at 22:45
  • mupdf try to update from the repository, I have a problem disappeared. – alezhka May 14 '12 at 08:43

4 Answers4

2

This problem is resolved by calling recycle() on bitmap in relaeseBitmaps() method of PageView.java

public void releaseBitmaps() {
        reinit();
        mEntireBm.recycle();
        mPatchBm.recycle();
        mEntireBm = null;
        mPatchBm = null;
    }
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
0

Inside mupdf.c find

"/* 128 MB store for low memory devices. Tweak as necessary. */" and

change the memory limit and try

I tried with 512 the rendering is faster than before

Sunny Kumar Aditya
  • 2,806
  • 4
  • 26
  • 38
0

I added the following code to force garbage collector in PageView.java and it seems to work okay so far.

if (mEntireBm == null || mEntireBm.getWidth() != newSize.x
                              || mEntireBm.getHeight() != newSize.y) {
            mEntireBm = Bitmap.createBitmap(mSize.x, mSize.y, Bitmap.Config.ARGB_8888);
            System.gc();//Added
            Runtime.getRuntime().gc();//Added
        }

Edited: it crashes after open the file several times

GoalGinger
  • 278
  • 1
  • 3
  • 7
-1
  1. Edit mupdf.c

Change: /* 128 MB store for low memory devices. Tweak as necessary. */ glo->ctx = ctx = fz_new_context(NULL, NULL, 128 << 20); to /* 128 MB store for low memory devices. Tweak as necessary. */ glo->ctx = ctx = fz_new_context(NULL, NULL, 32 << 20);

That`s all. Max heap memory amount ~50Mb.

3draven
  • 31
  • 4