Skip to content

Unsafe

Unsafe in Helix

By default, Helix handles memory management automatically through a built-in garbage collector, as mentioned in the Memory Management guide . This allows developers to focus on writing logic without worrying about allocation or deallocation errors.

However, in performance-critical or low-level systems programming scenarios, manual control over memory is sometimes necessary. For this, Helix provides the unsafe keyword.


What is Unsafe?

The ‘unsafe` keyword is used to mark memory allocations where the compiler and runtime no longer guarantee memory safety, essentially creating raw pointers, like those in C.

Declaring an unsafe pointer in helix is simple:

let address : unsafe *i32; //declares an i32 pointer