How do you check system memory usage?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

If i would like to debug the entire system memory usage, how would i do that? I was not able to find related API or defines that enable me to get or print logs that shows current system memory status.

Thanks in Advance.

0 Likes
1 Solution
Anonymous
Not applicable

Does mallinfo() work?

<WICED-SDK>/Apps/test/console/mallinfo/mallinfo.c

View solution in original post

5 Replies
ShawnA_01
Employee
Employee
10 questions asked 5 comments on KBA First comment on KBA
There may be a more appropriate or convenient way to do it, but have you tried looking at the .MAP file after the compilation process is done? 

For example, after building the snip.email demo within SDK-2.4.0 for the BCM943362WCD4 evaluation board, look at the file:  ~Documents/WICED/Wiced-SDK-2.4.0/WICED-SDK/build/snip_email-BCM943362WCD4/Binary/snip_email-BCM943362WCD4_map.csv

Here is a chunk from the very bottom of it:

---------------------------------- -------- ---------

                                              Static

Module                              Flash      RAM  

---------------------------------- -------- ---------

App                                489 0

Bootloader                         134 0

dhcp_server                        2271 132

dns                                2032 44

Host MCU-family library            14284 2626

Interrupt Vectors                  660 0

libc                               51370 2632

Networking                         4431 35356

NetX                               51770 644

Platform                           1014 0

RAM Initialisation                 2480 0

smtp                               3536 0

sntp                               706 56

Startup Stack & Link Script fill   465 852

Supplicant - BESL                  61436 436

ThreadX                            8752 392

Wi-Fi Firmware                     203268 0

Wiced                              6181 810

WWD                                15489 1068

---------------------------------- -------- ---------

TOTAL (bytes)                      430768 45048

---------------------------------- -------- ---------
0 Likes
Anonymous
Not applicable
There may be a more appropriate or convenient way to do it, but have you tried looking at the .MAP file after the compilation process is done?  

For example, after building the snip.email demo within SDK-2.4.0 for the BCM943362WCD4 evaluation board, look at the file:  ~Documents/WICED/Wiced-SDK-2.4.0/WICED-SDK/build/snip_email-BCM943362WCD4/Binary/snip_email-BCM943362WCD4_map.csv

Here is a chunk from the very bottom of it:

---------------------------------- -------- ---------

                                              Static

Module                              Flash      RAM  

---------------------------------- -------- ---------

App                                489 0

Bootloader                         134 0

dhcp_server                        2271 132

dns                                2032 44

Host MCU-family library            14284 2626

Interrupt Vectors                  660 0

libc                               51370 2632

Networking                         4431 35356

NetX                               51770 644

Platform                           1014 0

RAM Initialisation                 2480 0

smtp                               3536 0

sntp                               706 56

Startup Stack & Link Script fill   465 852

Supplicant - BESL                  61436 436

ThreadX                            8752 392

Wi-Fi Firmware                     203268 0

Wiced                              6181 810

WWD                                15489 1068

---------------------------------- -------- ---------

TOTAL (bytes)                      430768 45048

---------------------------------- -------- ---------

Hi Santol,

I was referring to real time system emory usage debug such as maximum allocated memory and current memory used from heap.
0 Likes
MuOr_1658816
Level 4
Level 4
First like received
I am wondering the same. Any answer to this?

Hi Santol,

I was referring to real time system emory usage debug such as maximum allocated memory and current memory used from heap.
0 Likes
Anonymous
Not applicable

Does mallinfo() work?

<WICED-SDK>/Apps/test/console/mallinfo/mallinfo.c

Anonymous
Not applicable

Static memory usage can be seen in the build output. 

To get information on dynamic memory usage, you can use mallinfo() as follows:

        volatile struct mallinfo mi = mallinfo();

Then look at the structure elements of variable "mi"

struct mallinfo {

  int arena;    /* total space allocated from system */

  int ordblks;  /* number of non-inuse chunks */

  int smblks;   /* unused -- always zero */

  int hblks;    /* number of mmapped regions */

  int hblkhd;   /* total space in mmapped regions */

  int usmblks;  /* unused -- always zero */

  int fsmblks;  /* unused -- always zero */

  int uordblks; /* total allocated space */

  int fordblks; /* total non-inuse space */

  int keepcost; /* top-most, releasable (via malloc_trim) space */

};

The "arena" that malloc & mallinfo use may not have expanded to fill your memory. To get the total size of the heap, you can look at the symbols _heap and _eheap.

FreeRTOS & LwIP use dynamic memory for most of their variables. ThreadX / NetX uses mostly static memory.

Regards,

Evan Hunter