mbed_stats_heap_get returns all 0's

09 Dec 2016

How can I get this cool mbed library heap function to work?

Makefile: I defined MBED_HEAP_STATS_ENABLED macro.

main() { ...

char* buf;

buf = (char*)malloc( 1000 );

printf("\n buf = %x", buf );

print_heap_stats();

}

void print_heap_stats( void ) {

Log heap stats:

mbed_stats_heap_t mbed_stats_heap;

mbed_stats_heap_get( &mbed_stats_heap );

printf("\n%s...\n %d current_size", FUNCTION, mbed_stats_heap.current_size );

printf("\n %d max_size", mbed_stats_heap.max_size );

printf("\n %d total_size", mbed_stats_heap.total_size );

printf("\n %d alloc_cnt", mbed_stats_heap.alloc_cnt );

printf("\n %d alloc_fail_cnt", mbed_stats_heap.alloc_fail_cnt );

}

OUTPUT................

buf = 20006dd0

print_heap_stats...

0 current_size

0 max_size

0 total_size

0 alloc_cnt

0 alloc_fail_cnt