lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2015-10-02 11:01 GMT+01:00 Marc Balmer <>:
> When I pass precompiled Lua bytecode to Lua using lua_loadXXX functions by passing a pointer to the bytecode in memory (e.g. after mmaping the file containing the byte code into memory), will that directly be used or will there new memory be allocated and the bytecode be copied?

I believe Peter Cawley already gave the most relevant answer (short of
looking at the source or an author answering directly), so I won't
expand on that.

A similar feature that has been asked before is to do that for
strings, for example to use read-only memory on low-RAM platforms. I
believe eLua has such a feature, and IIRC Roberto mentioned it (in a
recent workshop video) as a potential future feature for Lua. If that
ever makes it into Lua for strings, it would be nice to have the same
option for bytecode. But on the other hand, contrary to strings, the
runtime memory layout of the function prototypes may not be exactly
that of the serialized bytecode.