# Managed spell limited quantity **🟡 Intermediate · Lesson 43** Cap how many objects exist at once - managed_spell_mode="limited_quantity". managed_spell_limit (required here) is the most objects ALIVE at once: idle plus out. Below the limit a meld builds; at the limit, with nothing idle, the meld is refused with ManagedSpellExhaustedError before anything is built. The error is a MeldExecutionError that names the mode and the limit, and says how to get out: release an object, or bind a higher limit. Releasing frees a place: the next meld is served the released object, so the pool never grows past its limit. release_all(objects) gives many back at once. ## Before you run Use the [Intermediate guide](../../intermediate/index.md) for prerequisite concepts. Run from a checkout with Melder installed and Python 3.14 free-threading selected. The collection download includes the level's local helper modules. ## Run the saved script ```bash python UX_and_AIX_experiences/02_intermediate/43_managed_spell_limited_quantity.py ``` ```powershell py -3.14t UX_and_AIX_experiences/02_intermediate/43_managed_spell_limited_quantity.py ``` {download}`Download this collection <../../downloads/intermediate-examples.zip>` · [Source on GitHub](https://github.com/Synaptic724/melder/blob/4b364a338debcb1c010d0f6e9dcbbabb62945ba0/UX_and_AIX_experiences/02_intermediate/43_managed_spell_limited_quantity.py) ## Public surface md.Spellbook.bind (managed_spell_mode, managed_spell_limit), md.ManagedSpellMode.limited_quantity, md.Conduit.meld, md.ManagedSpellExhaustedError (mode, limit, timeout_seconds), md.MeldExecutionError, md.ReleaseManagedSpell (release, release_all, describe), md.Conduit.cleanup ## Code ```{literalinclude} ../../downloads/02_intermediate/43_managed_spell_limited_quantity.py :language: python :linenos: ``` ## Check the outcome The script contains its own assertions or demonstrated refusal paths. Run it to evaluate those checks against your installed version. The code above is taken directly from the saved file; no run output is invented here. [More intermediate examples](index.md) · [Level guide](../../intermediate/index.md) ## Related guides - [Managed spell pools](../../intermediate/managed-spells.md) ## API contracts - [Spellbook](../../reference/api/binding/spellbook.md) - [Conduit](../../reference/api/resolution/conduit.md) - [ManagedSpellMode](../../reference/api/resolution/managedspellmode.md) - [ReleaseManagedSpell](../../reference/api/resolution/releasemanagedspell.md) - [MeldExecutionError](../../reference/api/errors/meldexecutionerror.md) - [ManagedSpellExhaustedError](../../reference/api/errors/managedspellexhaustederror.md)