forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 0
Memory Use Analysis
Ken Bannister edited this page Dec 18, 2018
·
7 revisions
Use the approaches below to show memory use for an executable. In the examples below, we compile the gcoap example app for samr21-xpro.
The command below shows the full executable size as well as the size of compiled modules. You likely will want to focus in on a subset of the modules.
$ DEVELHELP=0 BOARD=samr21-xpro make clean all
text data bss dec hex filename
66640 920 16328 83888 147b0 /home/kbee/dev/riot/repo/examples/gcoap/bin/samr21-xpro/gcoap
$ DEVELHELP=0 BOARD=samr21-xpro make info-objsize |grep gcoap
2799 392 1298 4489 1189 gcoap.o (ex /gcoap.a)
1778 12 2 1792 700 gcoap_cli.o (ex /application_gcoap_example.a)
150 0 32 182 b6 main.o (ex /application_gcoap_example.a)
The command below further breaks down flash use to show the size of individual functions.
arm-none-eabi-nm -Sn -t d bin/samr21-xpro/gcoap_example.elf |grep gcoap |awk '{printf "%5u %s %s\n", $2, $3, $4}'
656 T gcoap_cli_cmd
16 T gcoap_cli_init
148 T gcoap_init
24 T gcoap_register_listener
100 T gcoap_req_init
92 T gcoap_finish
368 T gcoap_req_send2
78 T gcoap_resp_init
120 T gcoap_obs_init
52 T gcoap_obs_send
24 T gcoap_op_state
140 T gcoap_get_resource_list
Use the ps command to show allocated memory per thread stack as well as memory used. Must compile with DEVELHELP=1 (usually the default) to see this level of detail.
The command can be called from the CLI with ps
, or programmatically with ps()
.
pid | name | state Q | pri | stack ( used) | base addr | current
- | isr_stack | - - | - | 8192 ( -1) | 0x566775c0 | 0x566775c0
1 | idle | pending Q | 15 | 8192 ( 420) | 0x566752e0 | 0x56677154
2 | main | running Q | 7 | 12288 ( 3008) | 0x566722e0 | 0x56675154
3 | ipv6 | bl rx _ | 4 | 8192 ( 1680) | 0x566857e0 | 0x56687654
4 | udp | bl rx _ | 5 | 8192 ( 1008) | 0x56681700 | 0x56683574
5 | coap | bl mbox _ | 6 | 8276 ( 1572) | 0x5667dce0 | 0x5667fba8
6 | gnrc_netdev_tap | bl rx _ | 2 | 8192 ( 2352) | 0x566837c0 | 0x56685634
| SUM | | | 61524 (10040)