2

I'm searching for a way to see the RAM usage of my application running on an at32uc3b0512.

arv32-size.exe foo.elf tells me:

  text    data     bss     dec     hex filename
263498   11780   86524  361802   5854a foo.elf

According to 'google', RAM usage is .data + .bss. But .data + .bss is already (11780+86524)/1024 = 96kb, which would mean that my RAM is full (at32uc3b0512 -> 96kb SRAM). But the application works as desired. Am I wrong???

  • 2
    The .map file generated by the linker during the build should tell you the size of each section. And that could be a way to double check what arv32-size.exe is telling you. – kkrambo Apr 08 '15 at 14:07
  • Try `avr32-size -A`, the output tends to be more sane. See an older discussion at http://stackoverflow.com/questions/16791311/how-to-interpret-avr32-size-output . – Mike Bessonov Apr 08 '15 at 14:11
  • If I try avr32-size.exe -A, .data has the same size, but .bss is only 21664... Thus everything seams to be ok. But why does avr32-size.exe plot different values in different modes? – sharkscream Apr 08 '15 at 14:36
  • I have found similar issues with *-size utilities, except mine was under reporting RAM utilization. I'd recommend you submit your findings to the mailing list at avr-gcc – maguirre Apr 09 '15 at 00:46

2 Answers2

2

The chip you are using has 96kB of RAM and that is also the sum of your .bss and .data sections. This does not mean that all of your RAM is being used up, rather it is merely showing how the RAM is being allocated.

seansy
  • 95
  • 1
  • 6
0

The program on MCU is usually located in FLASH

  • this is not true if you have some OS present
  • and load program to memory on runtime from somewhere like SD card
  • not all MCU's can do that
  • I suspect that is not your case
  • The program Flash is 512 KByte big (I guess from your IC's number)

The SDRAM is used for C engine/OS,stack and heap

  • your chip has 96 KByte
  • the C engine is something like OS handling
  • dynamic allocations,heap,stack,subroutine calls
  • and including RTL used during compilation
  • and of coarse dummy Interrupt sub routines for unused interrupts...

When you compile program to ELF/HEX what ever

  • the compiler/linker tells you only
  • how big the program code and data is (located in program FLASH memory)
  • how big static variables you have
  • the rest is unknown until runtime itself

So if you need to know how big chunk of memory you take

  • then you need to extract it from runtime
  • by some RTL call to get memory status
  • or by estimating it yourself based on knowledge of
  • what your program does
  • how much of dynamic memory is used
  • heap/stack trashing/usage
  • recursions level, etc...
  • Or you can try to increasingly allocate memory until you hit out of memory
  • and count how big chunk you allocated altogether
  • then release it of coarse
  • the used memory is then ~ 96KB - altogether_allocated_memory
  • (+/-) granularity ...
Spektre
  • 49,595
  • 11
  • 110
  • 380