rusterlium / rustler

Safe Rust bridge for creating Erlang NIF functions
https://docs.rs/crate/rustler
Apache License 2.0
4.32k stars 225 forks source link

Implement simple allocator using enif_{alloc,free} #580

Closed filmor closed 4 months ago

filmor commented 9 months ago

Implement a Rust global allocator using Erlang's enif_alloc and enif_free.

Rumor has it that this makes Rust's memory usage show up in erlang:memory().

The tests are currently reproducibly seg-faulting on Linux x86-64 but run through on arm64.

filmor commented 7 months ago

TODO: Check with valgrind what's going on

dvic commented 6 months ago

Locally on my Mac M1 both the Rust and Elixir tests are passing fine, so it might be something specific to the CI?

filmor commented 6 months ago

Some notes:

filmor commented 5 months ago

Reading https://github.com/E-xyza/zigler/blob/main/priv/beam/allocator.zig brought the fix, this works now.

filmor commented 4 months ago

@evnu As requested, added more comments to the allocator.