Comment 18 for bug 132612

Revision history for this message
kripken (kripkenstein) wrote :

Ok, perhaps some progress on this matter.

This bothered me enough to try to get something done, so I talked to one of the Evince devs. Turns out part of the problem is that Evince always caches 2 pages forward and back. So even if you are viewing a single page, you have 5 pages rendered in memory. When pages are very 'heavy' this becomes a problem.

I have therefore written a patch to change the caching algorithm in Evince, in order to make it adaptive. The new method will cache pages ahead and back in a semi-smart manner, depending on the amount of free memory. If there is none, then it will only render pages currently in sight.

I sent the patch to the Evince dev; we'll see what they think. Meanwhile I am attaching it here as well, if someone wants to look at it, test it, etc. To do so, install Evince from svn (as explained here: http://live.gnome.org/Evince/GettingEvince ). Then apply the patch to the single file I modified (in the directory 'shell'). Then 'make install', etc.

On my 512MB system, I can now view PDFs that used to kill the computer (Evince still takes 100-200 MB, though). Results from other computers and files would be helpful, since the caching method I implemented has a heuristic for how to decide how many pages to cache, and I don't know if it is optimal in all cases. Details are inside the patch, in code comments, but basically it reads /proc/meminfo, calculates free memory, considers cached RAM and also used swap in order to decide how much should really be usable.

Comments, etc., are welcome.

(Note that this is far from solving all of Evince's memory issues. It still takes much more RAM than xPDF does, even page-for-page. But hopefully a step in the right direction.)