Bug 693330 - mupdf requires ~600mb of memory for 1 page PDF file
Summary: mupdf requires ~600mb of memory for 1 page PDF file
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: master
Hardware: PC Windows 7
: P4 normal
Assignee: Tor Andersson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-13 21:10 UTC by İsmail "cartman" Dönmez
Modified: 2014-02-17 04:43 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
PDF file to reproduce the issue (7.00 MB, application/pdf)
2012-09-13 21:10 UTC, İsmail "cartman" Dönmez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description İsmail "cartman" Dönmez 2012-09-13 21:10:58 UTC
Created attachment 8932 [details]
PDF file to reproduce the issue

This is extracted from a bigger PDF file. Runnind the mupdf viewer on the file (Windows 7 64bit) increases RAM usage by ~600mb. Testing the mupdf viewer on Android with the file just goes out of memory too.
Comment 1 Robin Watts 2012-10-02 12:08:59 UTC
I have a fix for this that reduces the memory use to ~30Meg. In review now.
Comment 2 Robin Watts 2012-10-10 16:18:10 UTC
Fixed in:

commit 4fbdba66f22d7388592c7946de16ec3ee79ade36
Author: Robin Watts <robin.watts@artifex.com>
Date:   Fri Sep 28 17:51:30 2012 +0100

    Bug 693330: Change shadings to decompose to meshes at render time.

    Currently, the mupdf code loads shadings at parse time, and
    instantly decomposes them into a mesh of triangles. This mesh
    of triangles is the transformed and rendered as required.

    Unfortunately the storage space for the mesh is typically much
    greater than the original representation.

    In this commit, we move the shading stream parsing/decomposition
    code into a general 'fz_process_mesh' function within res_shade.
    We then grab a copy of the buffer at load time, and 'process'
    (decompose/paint) at render time.

    For the test file on the bug, memory falls from the reported 660Mb
    to 30Mb. For another test file (txt9780547775815_ingested.pdf
    page 271) it reduces memory use from 750Meg to 33Meg. These figures
    could be further reduced by storing the compressed streams from the
    pdf file rather than the uncompressed ones.

    Incorporating typo fix and unused function removal from Sebras. Thanks.

    Remove unused function in shading code
Comment 3 Robin Watts 2012-10-10 16:18:31 UTC
Thanks for the bug report, and example file!
Comment 4 İsmail "cartman" Dönmez 2012-10-10 16:19:24 UTC
Thanks for the fix!