avr-chat
[Top][All Lists]
Advanced

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

RE: [avr-chat] How to determine how much SRAM is being used by global &s


From: Matt.VanDeWerken
Subject: RE: [avr-chat] How to determine how much SRAM is being used by global &static vars?
Date: Thu, 25 May 2006 13:42:40 +1000

You can look at this page for information about the various memory
spaces:

http://www.nongnu.org/avr-libc/user-manual/mem_sections.html

In short, the report given by the standard Makefile shipped with winAVR
will give you the output you require, for example:

section            size      addr
.data              1158   8421376
.text             17742         0
.bss               2135   8388864
.noinit               0   8390999
.eeprom               0   8454144
.stab              1032         0
.stabstr            132         0
.debug_aranges      484         0
.debug_pubnames    3476         0
.debug_info       20558         0
.debug_abbrev      6451         0
.debug_line       14976         0
.debug_str         5561         0
.debug_ranges        48     17742
Total             73753

The important numbers are .data and .bss; .data generally is static data
defined in code (in my case 1158 bytes), while .bss is unitialised
global or static variables (2135 bytes in my case). Note that .data can
often be minimised by simply assigning static strings as in program
space (see
http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html)

Generally, the sum of .data plus .bss plus any stack space you use must
be less than your total SRAM (if it isn't you will have problems). In my
case I have .data living in XRAM (I have 32k of XRAM), while I am
running freeRTOS which means all my stacks after the one initialised in
main() live in .bss, so it really isn't as dire as it would look on
first inspection of those numbers above.

Note also that any dynamically-allocated memory will not show up in
these numbers; you'd have to work out how much you dynamically allocate,
or alternatively work out a method for calculating free ram some other
way.

Cheers,
Matthew van de Werken - Electronics Engineer
CSIRO E&M - Rock Mass Characterisation - 1 Technology Court - Pullenvale
- 4069
p: (07) 3327 4142 * f: (07) 3327 4455 * e: address@hidden
"We do not inherit the earth from our ancestors, we borrow it from our
children." 
-- Native American Proverb

> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden
>  On Behalf Of Rick Mann
> Sent: Thursday, 25 May 2006 12:37 PM
> To: avr-chat
> Subject: [avr-chat] How to determine how much SRAM is being 
> used by global &static vars?
> 
> 
> How can I determine how much SRAM my global & static variables are  
> using up?
> 
> -- 
> Rick
> 
> 
> 
> 
> _______________________________________________
> AVR-chat mailing list
> address@hidden http://lists.nongnu.org/mailman/listinfo/avr-chat
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]