pwmt / zathura

Document viewer
https://pwmt.org/projects/zathura
zlib License
1.86k stars 127 forks source link

Zooming in on long pdfs causes memory leak #449

Open sebastinas opened 4 months ago

sebastinas commented 4 months ago

On GitLab by @sungodmoth on Feb 27, 2024, 16:04


(Note: This is similar to the issue reported in the (very old) issue #209. However, the reporter of that issue did not seem to encounter the boundless increase in memory usage that I have seen, and did not identify the problem as being restricted to long pdfs.)

Environment: Running i3wm on Manjaro Linux. zathura version 0.5.4, pdf-mupdf version 0.4.1.

Description: With most pdfs I am able to zoom as far as zathura allows me to, with no issue. But on long pdfs, seemingly those with >1000 or so pages, zooming far enough in causes a black screen, and zooming even further than that causes the image to return (but blurry) and zathura's memory usage, as reported by system utilities, rapidly rises (I'm talking about a rate of over a gigabyte per second) with no sign of stopping, until either zathura is closed or the document is again zoomed out, at which point it returns to normal.

Note that this is completely uncorrelated to the file size of the file, and seems to be solely caused by the page count. Zooming in on a pdf around 150MB in size but only 500 pages in length, the problem is absent. I have attached for reference a tiny 2000 page file (created by repeated self-concatenation of a minimal pdf) which is only 262KB in size, which displays the problem clearly.

long.pdf

(Note that this file throws some warnings, but they are irrelevant to this issue, which I experience with all pdfs of this length). The maximum amount that I can zoom before the black screen appears seems to decrease with the length of the pdf. If testing this is necessary, I've also attached a pdf of twice the length (but still tiny file size).

longer.pdf