gen2brain / go-fitz

Golang wrapper for the MuPDF Fitz library
GNU Affero General Public License v3.0
429 stars 97 forks source link

enable drop_pixmap after use to reduce memory usage #103

Closed singhsays closed 7 months ago

singhsays commented 8 months ago

Without this change pixmap allocation is held till GC, increasing memory usage, which adds up quickly with a large pdf with lots of pages

e.g. alloc_space:

Screenshot 2024-03-12 at 10 19 09 PM

isuse_space:

Screenshot 2024-03-12 at 10 19 36 PM
gen2brain commented 8 months ago

This line was commented on as it started crashing from some versions. I wanted to get back to this sometime. As I see, it still crashes, you tested this on what OS?

singhsays commented 7 months ago

Thanks for looking into this. I tested it on a MacOS M3 Macbook (arm64) and Debian 12 (amd64). I see that it fails on ImageDPI which I didn't test. I tested ImagePNG. Let me look more into it.

singhsays commented 7 months ago

I'll revert the change to ImageDPI till I can figure it out and fix

gen2brain commented 7 months ago

Ok, I merged this for ImagePNG. I still have no idea what happens in ImageDPI, if at least it crashes with "double free".