Oxidizing OCaml with Modal Memory Management
Programmers can often improve the performance of their programs by reducing heap allocations: either by allocating on the stack or reusing existing memory in-place. However, without safety guarantees, these optimizations can easily lead to use-after-free errors and even type unsoundness. In this paper, we present a design based on modes which allows programmers to safely reduce allocations by using stack allocation and in-place updates of immutable structures. We focus on three mode axes: affinity, uniqueness and locality. Modes are fully backwards compatible with existing OCaml code and can be completely inferred. Our work makes manual memory management in OCaml safe and convenient and charts a path towards bringing the benefits of Rust to OCaml.
Authors
- Anton Lorenzen (ORCID: https://orcid.org/0000-0003-3538-9688)
- Leo White (ORCID: https://orcid.org/0009-0003-7046-3035)
- Sam Lindley (ORCID: https://orcid.org/0000-0002-1360-4714)
- Richard A. Eisenberg (ORCID: https://orcid.org/0000-0002-7669-9781)
- Stephen Dolan (ORCID: https://orcid.org/0000-0002-4609-9101)
Institutions
- The Jane Goodall Institute (US)
- Jane Street (United States)
- University of Edinburgh (GB)
Publication Details
- Journal
- Proceedings of the ACM on Programming Languages
- Published
- 2024-08-15
- DOI
- https://doi.org/10.1145/3674642
- Citations
- 10
- Primary Topic
- Logic, programming, and type systems
- Type
- article
- Field-Weighted Citation Impact
- 3.47
Funders
- UK Research and Innovation