The Fix
pip install pydantic==1.10.18
Based on closed pydantic/pydantic issue #9982 · PR/commit linked
@@ -5,7 +5,7 @@
strategy = []
lock_version = "4.5.0"
-content_hash = "sha256:fed880fb16df36669085143f0cdd13d107aec46ffa217055b64d8d687f6ca9e2"
+content_hash = "sha256:e0aaf99826f0ab2aa870c1dafa4d9939c7a60160cb870f681769806ec45c4f5d"
@profile
def __rebuild_all_models() -> None:
# load models to the scope
import models # noqa
from models.unknown_type import UnknownType, UnknownInputType # noqa
for __model in __get_models_to_rebuild_set():
__model.model_rebuild()
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install pydantic==1.10.18\nWhen NOT to use: This fix should not be applied if the application relies on the previous memory handling behavior.\n\n
Why This Fix Works in Production
- Trigger: Thanks for reporting this issue. We're currently investigating reusing common types + schemas to improve performance and memory usage. We'll be sure to use…
- Mechanism: Memory usage increased significantly due to the handling of numerous complicated models in strict mode
- Why the fix works: Improves performance by skipping the caching of parent namespaces in most cases, addressing memory usage issues. (first fixed release: 1.10.18).
Why This Breaks in Prod
- Shows up under Python 3.9 in real deployments (not just unit tests).
- Memory usage increased significantly due to the handling of numerous complicated models in strict mode
- Production symptom (often without a traceback): python version: 3.9.6 (default, Mar 29 2024, 10:51:09) [Clang 15.0.0 (clang-1500.3.9.4)]
Proof / Evidence
- GitHub issue: #9982
- Fix PR: https://github.com/pydantic/pydantic/pull/10113
- First fixed release: 1.10.18
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.62
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Hmm, seems like a bug. Is there anyw ay you could give us a minimal snippet to reproduce that issue?”
“@sydney-runkle started to prepare a minimal snippet to reproduce, got it working, then updated to 2.9.0, and can't reproduce anymore! Downgraded to 2.8.2 and can…”
“@MarshalX, Thanks for reporting this issue. We're currently investigating reusing common types + schemas to improve performance and memory usage. We'll be sure to use…”
“Hi @MarshalX, Could you test this against the branch associated with https://github.com/pydantic/pydantic/pull/10064?”
Failure Signature (Search String)
- Thanks for reporting this issue. We're currently investigating reusing common types + schemas to improve performance and memory usage. We'll be sure to use this as a reference /
Copy-friendly signature
Failure Signature
-----------------
python version: 3.9.6 (default, Mar 29 2024, 10:51:09) [Clang 15.0.0 (clang-1500.3.9.4)]
Thanks for reporting this issue. We're currently investigating reusing common types + schemas to improve performance and memory usage. We'll be sure to use this as a reference / benchmark!
Error Message
Signature-only (no traceback captured)
Error Message
-------------
python version: 3.9.6 (default, Mar 29 2024, 10:51:09) [Clang 15.0.0 (clang-1500.3.9.4)]
Thanks for reporting this issue. We're currently investigating reusing common types + schemas to improve performance and memory usage. We'll be sure to use this as a reference / benchmark!
Minimal Reproduction
@profile
def __rebuild_all_models() -> None:
# load models to the scope
import models # noqa
from models.unknown_type import UnknownType, UnknownInputType # noqa
for __model in __get_models_to_rebuild_set():
__model.model_rebuild()
Environment
- Python: 3.9
- Pydantic: 2
What Broke
Increased memory usage by over 100MB upon startup, affecting application performance.
Why It Broke
Memory usage increased significantly due to the handling of numerous complicated models in strict mode
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.18
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/pydantic/pydantic/pull/10113
First fixed release: 1.10.18
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the application relies on the previous memory handling behavior.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
Version Compatibility Table
| Version | Status |
|---|---|
| 1.10.18 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.