You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Process-wide caches keep every processed document forever, so long-running hosts leak memory #148
Several static ConcurrentDictionary caches have no size limit and never evict anything:
Frontmatter/Frontmatter.cs:26: ProcessedFrontmatterCache, keyed on (Content, Options). It keeps the full text of every input document plus the full output string.
Frontmatter/YamlSerializer.cs:22: ParsedYamlCache. It keeps the text of every frontmatter block plus a parsed dictionary for each.
PropertyMerger.cs:17 and NameStandardizer.cs:16 hold one entry per property key. These are smaller, but they are also unbounded.
Failure scenario
The library gets used in long-running processes: a static-site generator in watch/serve mode, a web service that normalizes uploaded Markdown, or a bulk run over a large docs repository. Every distinct document, and every edited revision of it, stays reachable until the process exits.
A watcher re-processing a 50 KB page on every save adds about 100 KB (input plus output) per save and never frees it. A bulk run over 10,000 documents keeps all of them in memory after the run.
A cache hit is also only useful when the exact same content is processed again, which is uncommon in those workloads. The document-level cache therefore mostly costs memory.
Because the state is global, it has already caused wrong results: #130 is a stale-cache bug. There is also no way to reset it between tests.
Suggested fix / acceptance criteria
Drop ProcessedFrontmatterCache, or give it a size limit (a small LRU, or clear it once it passes N entries). Do the same for ParsedYamlCache.
Optionally add a public ClearCaches() so tests and hosts can reset state.
Add a test showing that processing many distinct documents does not grow the cache past the limit.
Area / suggested assignee: caching in Frontmatter.cs (ProcessedFrontmatterCache) and YamlSerializer.cs (ParsedYamlCache), plus the smaller caches in PropertyMerger/NameStandardizer. Owner: @matt-edmondson
Next step: remove the document-level cache or give it a size limit (LRU or clear at N entries), do the same for ParsedYamlCache, and consider a public ClearCaches(). Add a test showing the cache stays within its limit across many distinct documents.
Activity
matt-edmondson commentedon Sep 27, 2026
Triage
Frontmatter.cs(ProcessedFrontmatterCache) andYamlSerializer.cs(ParsedYamlCache), plus the smaller caches inPropertyMerger/NameStandardizer. Owner: @matt-edmondsonParsedYamlCache, and consider a publicClearCaches(). Add a test showing the cache stays within its limit across many distinct documents.Generated by Claude Code