How to read available memory in eLua

classic Classic list List threaded Threaded
6 messages Options
scdr scdr
Reply | Threaded
Open this post in threaded view
|

How to read available memory in eLua


How do I find out how much memory is avialable in eLua?

I found gcinfo, which shows how much is in use.  
Is that out of the whole memory pool?
e.g., if it shows 5 kb is that out of the total RAM on the microcontroller, or does it ignore some of the memory used
by eLua internally.

If that is not out of total RAM, how can I find out how much memory is available.

  Thanks
_______________________________________________
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: How to read available memory in eLua

Hi,


On Sat, Jul 20, 2013 at 3:55 AM, <[hidden email]> wrote:

How do I find out how much memory is avialable in eLua?

I found gcinfo, which shows how much is in use.  
Is that out of the whole memory pool?
e.g., if it shows 5 kb is that out of the total RAM on the microcontroller, or does it ignore some of the memory used
by eLua internally.

'gcinfo' is only Lua object, eLua uses more memory than that for other stuff. There is currently no way to know how much memory is actually in use, we might add that in a future version (although this is not a simple problem because of the way some allocators request memory).

Best,
Bogdan


If that is not out of total RAM, how can I find out how much memory is available.

  Thanks
_______________________________________________
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
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: How to read available memory in eLua

On 22 July 2013 18:21, Bogdan Marinescu <[hidden email]> wrote:
> On Sat, Jul 20, 2013 at 3:55 AM, <[hidden email]> wrote:
>> How do I find out how much memory is avialable in eLua?

The memory areas are statically declared in each board's "*_conf.h"
file.  For example in
src/platform/avr32/MIZAR32/mizar32_conf.h the lines:
#define MEM_START_ADDRESS     { ( void* )end, ( void* )( SDRAM + ELUA_FIRMWARE_S
IZE ) }
#define MEM_END_ADDRESS       { ( void* )( RAM_SIZE - STACK_SIZE_TOTAL - 1 ), (
void* )( SDRAM + SDRAM_SIZE - 1 ) }

defines two regions, one from "end" (of static data) to the bottom of
the stack area, and one un the SDRAM chip.  Most boards only have one
area.  Memory is allocated from this/these area/s when requested by
Lua through malloc(). gcinfo() and collectgarbage("count") only tell
you how much is being used by the Lua heap but there is no way to know
the total from eLua.

It would be quite simple to add a function to eLua, say to the cpu.*()
module to tell you how many bytes there are in the areas described
above.

   M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: How to read available memory in eLua

On 22 July 2013 19:06, Martin Guy <[hidden email]> wrote:
> gcinfo() and collectgarbage("count") only tell
> you how much is being used by the Lua heap but there is no way to know
> the total from eLua.

...other than adding elements to some temporary table and printing
collectgarbage("count"), and running that until the RAM is full...

    M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev
scdr scdr
Reply | Threaded
Open this post in threaded view
|

Re: How to read available memory in eLua

In reply to this post by scdr

Thanks.  I added the appropriate code to the LM3 platform, only tried it on my Stellaris Launchpad port so far.
Since it is a bit constrained on RAM, figured it would be handy to have some idea how much memory various features cost.
27,911 bytes in dynamic allocation area

http://forum.stellarisiti.com/topic/552-elua-for-stellaris-launchpad/

> ----- Original Message -----
> From: Martin Guy
> Sent: 07/22/13 10:06 AM
> To: eLua Users and Development List (www.eluaproject.net)
> Subject: Re: [eLua-dev] How to read available memory in eLua
>
> On 22 July 2013 18:21, Bogdan Marinescu <[hidden email]> wrote:
> > On Sat, Jul 20, 2013 at 3:55 AM, <[hidden email]> wrote:
> >> How do I find out how much memory is avialable in eLua?
>
> The memory areas are statically declared in each board's "*_conf.h"
> file. For example in
> src/platform/avr32/MIZAR32/mizar32_conf.h the lines:
> #define MEM_START_ADDRESS { ( void* )end, ( void* )( SDRAM + ELUA_FIRMWARE_S
> IZE ) }
> #define MEM_END_ADDRESS { ( void* )( RAM_SIZE - STACK_SIZE_TOTAL - 1 ), (
> void* )( SDRAM + SDRAM_SIZE - 1 ) }
>
> defines two regions, one from "end" (of static data) to the bottom of
> the stack area, and one un the SDRAM chip. Most boards only have one
> area. Memory is allocated from this/these area/s when requested by
> Lua through malloc(). gcinfo() and collectgarbage("count") only tell
> you how much is being used by the Lua heap but there is no way to know
> the total from eLua.
>
> It would be quite simple to add a function to eLua, say to the cpu.*()
> module to tell you how many bytes there are in the areas described
> above.
>
>  M
> _______________________________________________
> 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
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Re: How to read available memory in eLua

On 25 July 2013 07:09,  <[hidden email]> wrote:
> Thanks.  I added the appropriate code to the LM3 platform, only tried it on my Stellaris Launchpad port so far.
> Since it is a bit constrained on RAM, figured it would be handy to have some idea how much memory various features cost.
> 27,911 bytes in dynamic allocation area
>
> http://forum.stellarisiti.com/topic/552-elua-for-stellaris-launchpad/

Mmm. That's tight, but enough to run little Lua programs in.
Mainline eLua has been heavily optimized for minimal RAM usage.
My feeling is that the modules now take little in terms of RAM usage,
unless you eliminate modules that have explicit buffers, such as ADC
or the UART buffers.

 If you end up with a summary table of feature-versus-RAM-cost per
feature, that would be useful to post

   M
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev