Skip to content
FutureBlitz

    Install

    Learn

    Null safety and memory

    Nullable types, reference counting, Weak references, Defer, and the reports that find leaks.

    Two kinds of bug are common in programs that work with objects: using a reference that points at nothing, and memory that’s never given back. FutureBlitz rules out the first at compile time. Apart from the raw pointers used with C libraries, a type can only hold Null when it says so, with ?, and the compiler makes the code check before it uses one. It deals with the second by counting references: an object is freed the moment its last reference goes, with no garbage collector and no pauses. This area shows both. It also covers the Weak references that keep cycles from leaking, Defer for cleanup that runs however a block ends, and the leak reports that show what a program forgot.

    Tutorials

    1. Nullable types Say where a value can be missing with T?, and let the compiler check every use of it.
    2. Reference counting and lifetimes See exactly when an object is freed, and use Destroy to clean up as it goes.
    3. Weak references Break reference cycles with Weak<T> and [Weak Self], so objects that point at each other are freed.
    4. Defer Schedule cleanup to run when a block ends, however it ends.
    5. Leak reports Read the report a program prints when it ends with objects still alive, find the cycle, and fix it.

    The rules behind this area are in the language reference.

    Report an issue with this page or with FutureBlitz on GitHub.