.lua modules in memory

classic Classic list List threaded Threaded
4 messages Options
agostain agostain
Reply | Threaded
Open this post in threaded view
|

.lua modules in memory

Hi,

I want to know where the .lua modules in the romfs reside. Are they loaded to RAM at startup of my program?

I did some memory measurements(using mallinfo and collectgarbage) and I use respectively around 52Kb and 28KB. Are the used modules included in the lua ram or in the overall memory usage?

thanks for your help ;-)
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: .lua modules in memory

Hi,

On Thu, Aug 2, 2012 at 11:53 AM, agostain <[hidden email]> wrote:
> Hi,
>
> I want to know where the .lua modules in the romfs reside. Are they loaded
> to RAM at startup of my program?

If they are Lua code, then yes, they are loaded to RAM (but not
completely, rather into a small buffer) and then compiled to bytecode
(which will also stay in RAM), then executed. If they are bytecode (a
result of cross-compiling), the latest eLua memory optimizations will
read the bytecode directly from Flash, without using any RAM.

>
> I did some memory measurements(using mallinfo and collectgarbage) and I use
> respectively around 52Kb and 28KB. Are the used modules included in the lua
> ram or in the overall memory usage?

Both. Lua uses malloc to alloc memory. 52 vs 28 seems quite a bit of a
difference though. I never played with mallinfo, I'm wondering how
accurate this particular implementation is.

Best,
Bogdan

>
> thanks for your help ;-)
>
>
>
> --
> View this message in context: http://elua-development.2368040.n2.nabble.com/lua-modules-in-memory-tp7577645.html
> Sent from the eLua Development mailing list archive at Nabble.com.
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
agostain agostain
Reply | Threaded
Open this post in threaded view
|

Re: .lua modules in memory

This post was updated on .
BogdanM wrote
Hi,

On Thu, Aug 2, 2012 at 11:53 AM, agostain <[hidden email]> wrote:
> Hi,
>
> I want to know where the .lua modules in the romfs reside. Are they loaded
> to RAM at startup of my program?

If they are Lua code, then yes, they are loaded to RAM (but not
completely, rather into a small buffer) and then compiled to bytecode
(which will also stay in RAM), then executed. If they are bytecode (a
result of cross-compiling), the latest eLua memory optimizations will
read the bytecode directly from Flash, without using any RAM.

does it apply also for elua-0.8 or the bleeding edge version? I cross-compile the lua code.

Flash? I don't think the LPC1769 has flash enabled in elua.
 
So if I get it right all my cross-compiled lua modules that will be used by my application will reside in the RAM?

mallinfo is quite reliable... So my doubt is the following. I am trying to have a dynamic memory breakdown. What I know so far is:

total heap+stack usage is ~51KB

modules bytecode size: 13632bytes

various buffers on stack = 2048bytes

other variables on stack = ~500bytes

so I am still around ~16KB

I know the program execution has tables etc. but for an amount of 34KB!?!? So I was wondering what it might be the remaining part. For example the lua interpreter...or something else. what about the C modules?






>
> I did some memory measurements(using mallinfo and collectgarbage) and I use
> respectively around 52Kb and 28KB. Are the used modules included in the lua
> ram or in the overall memory usage?

Both. Lua uses malloc to alloc memory. 52 vs 28 seems quite a bit of a
difference though. I never played with mallinfo, I'm wondering how
accurate this particular implementation is.

Best,
Bogdan

>
> thanks for your help ;-)
>
>
>
> --
> View this message in context: http://elua-development.2368040.n2.nabble.com/lua-modules-in-memory-tp7577645.html
> Sent from the eLua Development mailing list archive at Nabble.com.
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
BogdanM BogdanM
Reply | Threaded
Open this post in threaded view
|

Re: .lua modules in memory

HI,

On Fri, Aug 3, 2012 at 9:58 AM, agostain <[hidden email]> wrote:

>
> BogdanM wrote
>>
>> Hi,
>>
>> On Thu, Aug 2, 2012 at 11:53 AM, agostain &lt;agostino.difiglia@&gt;
>> wrote:
>>> Hi,
>>>
>>> I want to know where the .lua modules in the romfs reside. Are they
>>> loaded
>>> to RAM at startup of my program?
>>
>> If they are Lua code, then yes, they are loaded to RAM (but not
>> completely, rather into a small buffer) and then compiled to bytecode
>> (which will also stay in RAM), then executed. If they are bytecode (a
>> result of cross-compiling), the latest eLua memory optimizations will
>> read the bytecode directly from Flash, without using any RAM.
>>
>> *does it apply also for elua-0.8 or the bleeding edge version? I
>> cross-compile the lua code.

Bleeding edge only.

>>
>> Flash? I don't think the LPC1769 has flash enabled in elua.

I mean the internal MCU flash. If you have ROMFS enabled, you are
already using the internal flash.

>>
>> So if I get it right all my cross-compiled lua modules that will be used
>> by my application will reside in the RAM? *

No. If they are cross-compiled in flash, the bytecode will be read
directly from flash. Your program data will still be in RAM,
obviously.

Best,
Bogdan

>>
>>>
>>> I did some memory measurements(using mallinfo and collectgarbage) and I
>>> use
>>> respectively around 52Kb and 28KB. Are the used modules included in the
>>> lua
>>> ram or in the overall memory usage?
>>
>> Both. Lua uses malloc to alloc memory. 52 vs 28 seems quite a bit of a
>> difference though. I never played with mallinfo, I'm wondering how
>> accurate this particular implementation is.
>>
>> Best,
>> Bogdan
>>
>>>
>>> thanks for your help ;-)
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://elua-development.2368040.n2.nabble.com/lua-modules-in-memory-tp7577645.html
>>> Sent from the eLua Development mailing list archive at Nabble.com.
>>> _______________________________________________
>>> eLua-dev mailing list
>>> eLua-dev@.berlios
>>> https://lists.berlios.de/mailman/listinfo/elua-dev
>> _______________________________________________
>> eLua-dev mailing list
>> eLua-dev@.berlios
>> https://lists.berlios.de/mailman/listinfo/elua-dev
>>
>
>
>
>
> --
> View this message in context: http://elua-development.2368040.n2.nabble.com/lua-modules-in-memory-tp7577645p7577647.html
> Sent from the eLua Development mailing list archive at Nabble.com.
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev