Example to demonstrate usage of mbed_stats_stack_get_each API

Fork of heap_stats_example by mbed_example

main.cpp

Committer:
deepikabhavnani
Date:
2018-08-30
Revision:
2:cbb9a9884f45
Parent:
0:a5479359bf28
Child:
3:c084f1df237e

File content as of revision 2:cbb9a9884f45:

#include "mbed.h"
#include "mbed_stats.h"

int main(void)
{
    mbed_stats_heap_t heap_stats;

    printf("Starting heap stats example\r\n");

    void *allocation = malloc(1000);
    printf("Freeing 1000 bytes\r\n");

    mbed_stats_heap_get(&heap_stats);
    printf("Current heap: %lu\r\n", heap_stats.current_size);
    printf("Max heap size: %lu\r\n", heap_stats.max_size);

    free(allocation);

    mbed_stats_heap_get(&heap_stats);
    printf("Current heap after: %lu\r\n", heap_stats.current_size);
    printf("Max heap size after: %lu\r\n", heap_stats.max_size);
}