jcmoyer / rust-lua53

Lua 5.3 bindings for Rust
MIT License
158 stars 45 forks source link

Different memory allocation strategies #48

Open therustmonk opened 8 years ago

therustmonk commented 8 years ago

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:

SpaceManiac commented 8 years ago

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.

therustmonk commented 8 years ago

@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?

SpaceManiac commented 8 years ago

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.