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
Decoder adapter caches grow without bound when models are created per request #174
The pydantic and msgspec decoders cache one adapter per model in a plain dict (src/httpware/decoders/_caching.py). The cache holds a strong reference to every model it has seen and never evicts. Code that builds a model per request, for example with pydantic.create_model, grows the cache, and keeps those classes alive, for the life of the decoder.
How to confirm: decode through 10,000 models made with create_model and watch len(decoder._adapters) and the process RSS.
Options if it reproduces: a bounded LRU, or documenting that response models must be long-lived. Either needs a check of what it costs on a cache hit, since the lookup runs on every decoded request.
Activity