IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

The value lifecycle

A Mojo value has a beginning and an end. Mojo creates and initializes the value before you use it, then destroys it when it's no longer needed. Along the way, the value may be copied, moved, or transferred to another owner.

Lifecycle methods let you customize how your types create values, manage their state, and release resources. Mojo handles much of this automatically, while giving you control when your types need it. Register and trivial types simplify the lifecycle by eliminating operations they don't need.