[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Libraries and the Heap
- From: "Leinen, Rick" <RLeinen@...>
- Date: Thu, 24 Jul 2014 16:13:24 +0000
> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On Behalf Of Roberto Ierusalimschy
> Sent: Thursday, July 24, 2014 6:52 AM
> To: Lua mailing list
> Subject: Re: Libraries and the Heap
>
> > 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
Thanks Roberto. Evidently I got some incorrect information, or I misunderstood. What you describe follows with what I found in the code. This is good news!
Rick