2 releases

0.1.2 Oct 22, 2022
0.1.1 Oct 22, 2022
0.1.0 Oct 19, 2022

#98 in #alloc

Download history 10/week @ 2024-02-19 31/week @ 2024-02-26 7/week @ 2024-03-04 119/week @ 2024-03-11 3/week @ 2024-03-18 4/week @ 2024-03-25 49/week @ 2024-04-01

176 downloads per month
Used in 2 crates (via golana-loader)

MIT license

15KB
340 lines

smalloc

A small memory allocator for Solana programs


lib.rs:

Smalloc is a small and simple memory allocator for Solana programs.

Usage:

  1. Add this crate as dependency

  2. Add a dummy feature called "custom-heap" in Cargo.toml:

[features]
default = ["custom-heap"]
custom-heap = []
  1. Put this in your entrypoint.rs
// START: Heap start
// LENGTH: Heap length
// MIN: Minimal allocation size
// PAGE_SIZE: Allocation page size
#[cfg(target_os = "solana")]
#[global_allocator]
static ALLOC: Smalloc<{ HEAP_START_ADDRESS as usize }, { HEAP_LENGTH as usize }, 16, 1024> =
    Smalloc::new();

Note: The "dynamic_start" feature is for unit tests.

No runtime deps

Features