Phil, thank you for your help. I can confirm that closing and reopening PDF while processing every X pages helps to free memory. It’s building up and releasing properly, my heart rate increased when it built up to 750MB, but then immediately it went down to ~400.
Oh and btw. I’ve tested this time with 10 000 pages where before it was crashing on 5k pages.