gen2brain / go-fitz

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

enable drop_pixmap after use to reduce memory usage #103

Closed singhsays closed 3 months ago

singhsays commented 3 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 3 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 3 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 3 months ago

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

gen2brain commented 3 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".