Repository navigation
docs: 2.0 memory contract (0252) and its implementation tasks - #593
Merged
Merged
Conversation
Ruslan approved the 0252 plan as recommended: no allocator parameters in 2.0, bad_alloc only for system out-of-memory (budgets are ResourceLimitExceeded, as in 0250), Render(ostream&) stays all-or-nothing, RenderTo into a string or an output sink plus a header-only ContainerSink, and ReleaseThreadCaches(). docs/api-2.0.md gains section 3.9, decision 7 and the rejected options; the plan goes to docs/design. Files tasks 0256 (allocation-failure crashes), 0257 (RenderTo), 0275 (ReleaseThreadCaches) and 0276 (user docs); 0252 is done. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QEfqEiJoJF5wCn3xZSp8zW
rmorozov
marked this pull request as ready for review
October 18, 2026 15:11
…0279) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QEfqEiJoJF5wCn3xZSp8zW
…implies Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QEfqEiJoJF5wCn3xZSp8zW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Ruslan · project thread
Before: the 2.0 API document said nothing about where Jinja2C++ allocates, what it keeps per thread, how out-of-memory surfaces, or how output can go anywhere but an
ostreamor a fresh string.After: docs/api-2.0.md section 3.9 states the memory contract Ruslan approved on 2026-10-18, and four implementation tasks carry it out.
Decisions (all as recommended in the plan):
Valueand its containers stay onstd::allocator. A later hook would be an additiveTemplateEnvmethod taking astd::pmr::memory_resource&.std::bad_allocis only for system out-of-memory. Every limit and every spent budget isResourceLimitExceeded, matching 0250 (docs: 2.0 error contract (0250) and untrusted-input mode tasks #584).Render(ostream&)stays all-or-nothing.RenderTo(StringType&)andRenderTo(BasicOutputSink&)overloads, plus a header-onlyContainerSinkthat also coversfmt::memory_buffer. fmt stays a private dependency.ReleaseThreadCaches(): frees what renders keep on a thread, including the last environment's globals, which are currently retained after theTemplateEnvis destroyed.How: this is a docs-only PR.
RenderToand the sink.ReleaseThreadCaches.Notes for the merge steward:
docs/tasks/0253-*file.Roles: architect (plan, with an OOM fault-injection probe). Verifier not run (docs only). Pushes red in CI: none so far.
Generated by Claude Code