rust-lua53 icon indicating copy to clipboard operation
rust-lua53 copied to clipboard

Different memory allocation strategies

Open therustmonk opened this issue 9 years ago • 3 comments

Rust uses jemalloc for binaries (if possible), but lua's states created with luaL_newstate uses default system allocator. Different allocation strategies makes memory management wild.

What about to use lua_newstate directly with Rust's default allocator. With rust-lang/rust#27389 feature allocator can be overriden and it's cool to use homogeneous allocation strategy, fully managed by developer (inside and outside lua).

We can implement it as pluggable feature :+1:

therustmonk avatar Jul 07 '16 11:07 therustmonk

Do you think it's important to expose custom allocation at the library level, or would it be sufficient to override the system allocators with Rust allocators? If the latter, I can open a PR with an I-think-working implementation.

SpaceManiac avatar Jul 08 '16 02:07 SpaceManiac

@SpaceManiac I mean to use alloc feature which wraps RFC's generics. I've pushed my idea with #52 how I made it. What about your version?

therustmonk avatar Jul 08 '16 09:07 therustmonk

I worked on an implementation which would be usable on stable, essentially accessing the allocations API through the stable interface exposed by Vec. I can open a PR with it, but I need to work out alignment behavior.

SpaceManiac avatar Jul 09 '16 00:07 SpaceManiac