Overview, Total memory use – Echelon FTXL User Manual

Page 194

Advertising
background image

182

Determining Memory Usage for FTXL Applications

Overview

The FTXL LonTalk protocol stack allocates memory dynamically, so a direct

measurement of the memory usage might lead to an underestimate for memory
usage, especially for peak usage conditions. This appendix provides both static

code analysis and runtime measurements so that you can calculate more reliable

memory usage estimates.

Total Memory Use

After you create your FTXL application and compile it, you can determine how

much flash memory and RAM the application requires.
When you compile a project, the Nios IDE displays the size of the executable file
(.elf) in the IDE’s Console view, for example:

Info: (FTXL_Simple_0.elf) 579 KBytes program size (code +
initialized data).
Info: 15804 KBytes free for stack + heap.

You can also run the nios2-elf-size utility from a Windows command line to shows

the size of sections (program and data) within the executable file, for example:

C:\>nios2-elf-size FTXL_Simple_0.elf

text data bss dec hex filename

540492 8704 44300 593496 90e58 FTXL_Simple_0.elf

The output from the utility shows the following information:

• Text size, which represents the size of the program code
• Data size, which represents the size of initialized data
• Bss size, which represents the size of uninitialized data
• Total size in decimal
• Total size in hexadecimal
• The file name

The nios2-elf-size utility is in the [

Altera

]\nios2eds\bin\nios2-gnutools\H-i686-

pc-cygwin\bin directory. You run the utility against your executable file, which

is in the \Debug (or \Release or other build configuration) directory for your
project.
You can determine the flash requirements for an application directly from the

text, data, and bss output of the nios2-elf-size utility (or the program size listed
in the Console view after a project build). For the FTXL_Simple_0.elf file shown

above, the flash requirement is 593 496 bytes (579 KB).
You can potentially reduce the code size by modifying some of the settings for the
project’s system library, which include the settings for the operating system.
To determine the RAM requirements for the application, you need to include the
heap and stack usage for the program. Because the heap and stack are allocated

at runtime, you need to gather heap and stack information while the application

program is running. One way to gather this information is to use the mallinfo()
function, and interpret the uordblocks field of the mallinfo structure as the heap

size. You should call the mallinfo() function after your program completes the

Advertising