Skip to content

feat: add TypstCompiler.EvictCache to release the compilation cache - #54

Merged
evolvedlight merged 1 commit into
evolvedlight:developfrom
swisspost:personal/evict-cache
Oct 14, 2026
Merged

evolvedlight merged 1 commit into
evolvedlight:developfrom
swisspost:personal/evict-cache

Conversation

@dev-miko

Copy link
Copy Markdown
Contributor

Typst's compilation cache is process-global and was only trimmed with comemo::evict(10) after each compilation, so memory used by a large document stayed allocated for the next ten compilations with no way to release it sooner.

EvictCache() clears the cache completely. It is safe while other threads compile and leaves compiled documents valid; the per-compilation trim is unchanged.

A test binary with a counting global allocator asserts that clearing the cache releases what a compilation cached, and fails if eviction is a no-op.

Typst's compilation cache is process-global and was only trimmed with
comemo::evict(10) after each compilation, so memory used by a large
document stayed allocated for the next ten compilations with no way to
release it sooner.

EvictCache() clears the cache completely. It is safe while other threads
compile and leaves compiled documents valid; the per-compilation trim is
unchanged.

A test binary with a counting global allocator asserts that clearing the
cache releases what a compilation cached, and fails if eviction is a
no-op.
@evolvedlight
evolvedlight merged commit 9a1ef83 into evolvedlight:develop Oct 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants