lua-users home
lua-l archive

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


> When I first started my Lua project, I ran into a problem with it crashing as the standard Lua libraries were loading.  It turned out that my heap size was too small.  That's when I discovered that Lua libraries are loaded into the heap, in my embedded case, copying the routines from flash into DRAM (or so I've been told).  Not an efficient use of memory.  I understand that eLua leaves the libraries in non-volatile memory.
> 
> My question is this; I assume libraries that I create will also be loaded into the heap.  Is this correct?

Lua does not copy any C code to anywhere. Lua 5.1 (and previous versions)
creates a small structure in the heap (~3 words) to represent each C
function that is loaded. Lua 5.2 creates nothing in the heap when you
register a function. All versions create a table in the heap to represent
the entire library (~(8 + 6n) words) plus strings with the names
of the functions. (I guess this table and strings are what eLua avoids.)

-- Roberto