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

alloc

Implements layout-aware memory allocation and deallocation.

This module provides alloc and free functions that pair with a Layout descriptor to express the size and alignment of an allocation at the call site, making ownership and layout information explicit and co-located.

Structs

  • Layout: Describes the shape of a memory allocation for elements of type T.

Functions

  • alloc: Allocates contiguous storage for layout.count() elements of T.
  • free: Frees memory previously allocated with alloc.