Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of memory_tracing_example by
main.cpp
- Committer:
- deepikabhavnani
- Date:
- 2018-08-30
- Revision:
- 3:c084f1df237e
- Parent:
- 2:cbb9a9884f45
File content as of revision 3:c084f1df237e:
#include "mbed.h"
#include "mbed_stats.h"
int main(void)
{
mbed_stats_heap_t heap_stats;
printf("Starting heap stats example\r\n");
mbed_stats_heap_get(&heap_stats);
printf("Start; Current heap: %lu\n", heap_stats.current_size);
printf("Start; Max heap size: %lu\n", heap_stats.max_size);
printf("\nAllocating 1000 bytes\n");
void *allocation = malloc(1000);
mbed_stats_heap_get(&heap_stats);
printf("Post-Alloc; Current heap: %lu\n", heap_stats.current_size);
printf("Post-Alloc; Max heap size: %lu\n", heap_stats.max_size);
free(allocation);
printf("\nFreed 1000 bytes\n");
mbed_stats_heap_get(&heap_stats);
printf("Post-Free; Current heap: %lu\n", heap_stats.current_size);
printf("Post-Free; Max heap size: %lu\n", heap_stats.max_size);
}
