Juliacon 2024

Writing allocation-free Julia code with AllocCheck.jl
07-11, 11:10–11:20 (Europe/Amsterdam), Method (1.5)

Avoiding allocations is crucial when writing performant Julia, so we developed AllocCheck.jl, a package that provides tools for developing and statically enforcing allocation-free code.


In this talk we will present AllocCheck.jl and give a quick example of how to use it, touring it's functionality and possible applications. Specifically around it's main entry point `@check_allocs, which is used to check whether a function allocates or not.

We'll dive into the three major sources of allocations in Julia code (object creation, dynamic dispatch, allocations by the runtime) and show how AllocCheck.jl can help you identify where in your code these problems arose. You'll see some of the common challenges and solutions when writing allocation-free code, and how to dive further with other tools in the ecosystem (such as Cthulhu.jl).

This tool also makes it possible to deploy Julia safely for specialized applications, such as running long simulation loops on embedded hardware where allocation-free code is vital for safe operation of your hardware. In this talk, we'll break apart what's needed to safely write code for these stringent applications and what extra requirements this implies for your code.

AllocCheck.jl works by inspecting the optimized LLVM IR and doing static analysis over it, figuring out if and where allocations happen, what is type of the objects being allocated, and if the allocation site is in an error path.

Compiler engineer at JuliaHub and open source enthusiast.

This speaker also appears in: