memory

Use InlineArray and Span for zero-copy memory access in Swift.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/mazicimert/RunDom --skill memory-mazicimert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memory
Source: https://github.com/mazicimert/RunDom/tree/main/.claude/skills/swift/memory
Command: npx skills add https://github.com/mazicimert/RunDom --skill memory-mazicimert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Swift memory management often incurs heap allocations or unsafe pointer usage in performance-critical paths. This skill provides InlineArray and Span-based alternatives that offer fixed-size storage and safe, zero-cost access to memory.

Core Features & Use Cases

  • InlineArray: fixed-size storage with no heap allocation.
  • Span and MutableSpan: safe, non-escapable access to contiguous memory.
  • RawSpan / MutableRawSpan / UTF8Span / OutputSpan: safe byte-level and text-processing primitives.
  • Suitable for binary parsing, embedded Swift, and high-performance data processing.

Quick Start

Initialize an InlineArray<4, Int> with values and access them safely through a Span to demonstrate zero-copy memory access.

Frequently Asked Questions about memory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid heap allocations in Swift performance-critical code paths?

Avoid heap allocations in Swift by using InlineArray for fixed-size storage and Span for safe, zero-copy memory access. These primitives provide zero-overhead memory management without requiring unsafe pointer operations in high-throughput scenarios.

What is a Span in Swift and how does it handle contiguous memory?

A Span in Swift is a non-escapable primitive that provides safe, zero-cost access to contiguous memory. It enables efficient binary parsing and data processing by allowing direct, readable views into memory without copying overhead.

Can I use zero-copy memory access for embedded Swift projects?

Yes, zero-copy memory access is suitable for embedded Swift projects. The approach uses InlineArray and various Span types like RawSpan and MutableRawSpan to provide safe, fixed-size storage and byte-level access in constrained environments.

How do I initialize an InlineArray and access it through a Span?

Initialize an InlineArray by specifying its fixed count and element type, such as InlineArray<4, Int>, then access its values safely through a Span. This combination demonstrates zero-copy memory access without heap allocations.

What are the limitations of using InlineArray for fixed-size storage?

InlineArray is limited to fixed-size storage scenarios, meaning the size must be known at compile time. It is designed specifically for performance-critical paths requiring zero-overhead access rather than dynamic, resizable data structures.