I have a largish document: 4000 pages, each with an Autograph/Fletcher chart. Each of those charts has up to 10 JPGs.
It takes some five minutes to compile locally from the command line. Within its first minute, I can see it is using all my 32GiB of memory, and then the system paging files start growing.
That’s not the problem.
That compiles correctly, and it is a testament to the quality of Typst’s code that Typst doesn’t crash; and I have a new-found if grudging admiration for Window’s memory management, as I can continue to run other apps at the same time with no problems.
The problem comes when I try to add a different header for each of the 4000 pages.
That compile fails in moments with the message: thread ‘main’ has overflowed its stack. It does not look like an out-of-memory failure.
If I feed Typst a cut-down version of the document, Typst will work when there are under around 200 pages. Bigger than that, it crashes.
My work-around:
If I replace the header on each page with an equivalent line of text, that happily works for all 4000 pages. To be specific, if every page starts with this, we have a quick crash:
#pagebreak()
#set page(header: context [
title
#h(1fr)
#counter(page).display(
"1 of 1",
both: true,
) #line(stroke: (blue + 0.2pt), length: 100%)
])
While this works:
#pagebreak()
#context[
title
#h(1fr)
#counter(page).display("1 of 1", both: true,)
]
I tried creating a short doc to upload. I write a #WHILE loop to produce 4000 pages that look reasonably like the original doc. But this did not crash. Many subtle differences, like I am not using 10000 different images. Too many subtle differences for me to spend much more time on that.
So …… My question: is there an instrumented / debug version of Typst that I can use that will produce a diagnostic file that you can look at?
typst -V
typst 0.14.2 (b33de9de)