Skip to content

Ownership & Move Semantics

Flame achieves high performance and complete memory safety through a compile-time ownership model inspired by Rust. This eliminates both memory leaks and the unpredictable latency spikes of a Garbage Collector (GC).


  1. Every value in Flame has a variable that is called its owner.
  2. There can only be one owner at a time.
  3. When the owner goes out of scope, the value is dropped automatically from memory (RAII).

When a variable is assigned to another variable or passed by value to a function, ownership of the data is moved:

fn consume_data(s: String) {
print($"Received: {s}")
} // `s` is dropped here when the function exits
let original = "Hello Flame"
// Ownership is transferred (moved) to `consume_data`
consume_data(original)
// ERROR: `original` was moved and is no longer valid!
// print(original)

Memory is freed the moment an owner exits its lexical { ... } block:

{
let buffer = [1, 2, 3, 4, 5]
print(buffer.len()) // 5
} // `buffer` goes out of scope; heap allocation is freed immediately!
// `buffer` is inaccessible here