On this page
Ownership and Lifetimes๏
Reader Question๏
Where do live objects belong, and when are they reused or disposed?
Short Answer๏
Melder assigns every resolved object to an explicit lifetime boundary. The broadest
objects belong to a frame; narrower objects belong to conduits, conduit lineages,
clusters, or request-local spell spaces; many produces a new object per meld; and
managed_spell_quantity leases objects from a pool the owning root keeps, each one
returning to that pool only when its holder releases it. Cleanup walks owned scopes
inward-to-outward and disposes objects in reverse creation order.
Lifetime Choices๏
Existence |
Reuse boundary |
Typical role |
|---|---|---|
|
Aetheric frame |
Configuration, pools, shared services |
|
One conduit |
Session or request scope |
|
Root and lesser-conduit family |
Context shared down a scope tree |
|
Named conduit group |
Coordinated cross-scope service |
|
One leased spell space |
Request-local ephemeral state |
|
None |
Fresh workers or value-producing services |
|
Root-owned pool per spell version |
Objects reused after each release |
Managed Spells Are Leased๏
managed_spell_quantity binds classes only, and each spell version gets one pool in its
owning root's store. A meld, or an injection into a constructor during a meld, takes an
idle object from that pool, or builds a new one when the pool's mode allows. The holder
keeps the object until it gives it back: ReleaseManagedSpell().release(obj), or a
ManagedSpellLease from ReleaseManagedSpell().managed(obj) or
Conduit.managed_spell_meld(...), which releases once, by release() or at the end of
its with block. A release runs the reset methods named at bind, in order, and leaves
the object idle for the next lease; a reset that raises destroys the object instead.
Nothing gives an object back automatically: one never released stays out, and in a
limited_quantity or queue pool it holds its place until the root ends.
The mode is chosen at bind with managed_spell_mode:
elastic, the default, always builds on a miss and keeps at mostmanaged_spell_limitidle objects (256 unless set), trimming idle objects as demand falls;limited_quantityallows at mostmanaged_spell_limitobjects alive, idle plus out, and refuses a lease that finds nothing idle at that limit, before building anything;queuehas the same limit, but such a lease waits up tomanaged_spell_timeout_secondsfor a release before it is refused.
A managed spell may depend on unique, other managed, and many spells (its many
objects belong to the object they were built for), and any spell may depend on it. The
pool lives with its root: an ownership transfer carries it, and the root's teardown
disposes its idle objects. Objects that are out belong to whoever holds them.
Cleanup Is Part of the Model๏
Creation stores preserve registration order for teardown. Newer dependents are disposed before earlier dependencies, and failures are aggregated so one bad disposer does not prevent the remaining scope from being cleaned.
A root's store cleans its managed pools first, so idle pooled objects are disposed
before the unique objects they hold. A pool runs disposal methods only when it
destroys an object (when it trims idle objects, when a reset raises, or at teardown),
never on a release.
Why This Design Is Strong๏
Scope is expressed in the same graph that creates objects. The runtime therefore knows which store may reuse an instance and which owner must eventually dispose it.
Tradeoffs๏
Application authors must choose lifetimes and teardown vocabulary explicitly. That cost buys predictable reuse, deterministic cleanup, and fewer hidden process-wide singletons.
Where to Go Next๏
Source entry points: