limit-alloc 0.1.0

A custom allocator that allows to limit the available memory
Documentation
  • Coverage
  • 41.67%
    5 out of 12 items documented0 out of 10 items with examples
  • Size
  • Source code size: 42.46 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.04 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Badel2/limit-alloc
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Badel2

limit-alloc

A custom allocator that allows to limit the available memory.

Usage

use limit_alloc::Limit;
use std::alloc::System;

// Limit available RAM to 4MB
#[global_allocator]
static A: Limit<System> = Limit::new(4_000_000, System);

fn main() {
    let _huge_vec: Vec<u8> = Vec::with_capacity(4_000_001);
}

You can run that example locally and see how the process crashes:

$ cargo run --example huge_vec
memory allocation of 4000001 bytes failed
Aborted