Jump to solution
Verify

The Fix

pip install pydantic==1.10.18

Based on closed pydantic/pydantic issue #9982 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -5,7 +5,7 @@ strategy = [] lock_version = "4.5.0" -content_hash = "sha256:fed880fb16df36669085143f0cdd13d107aec46ffa217055b64d8d687f6ca9e2" +content_hash = "sha256:e0aaf99826f0ab2aa870c1dafa4d9939c7a60160cb870f681769806ec45c4f5d"
repro.py
@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()
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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

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 · 2024-08-26 · repro detail · source
“@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 · 2024-09-07 · repro detail · source
“@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…”
@sydney-runkle · 2024-07-26 · source
“Hi @MarshalX, Could you test this against the branch associated with https://github.com/pydantic/pydantic/pull/10064?”
@sydney-runkle · 2024-08-06 · source

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
signature.txt
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.txt
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

repro.py
@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

When NOT to use: This fix should not be applied if the application relies on the previous memory handling behavior.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be applied if the application relies on the previous memory handling behavior.

Verify Fix

verify
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

VersionStatus
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.