Example to demonstrate usage of heap stats

Fork of memory_tracing_example by mbed_example

Revision:
3:c084f1df237e
Parent:
2:cbb9a9884f45
--- a/main.cpp	Thu Aug 30 16:42:01 2018 +0000
+++ b/main.cpp	Thu Aug 30 16:47:16 2018 +0000
@@ -6,17 +6,22 @@
     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);
-    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);
+    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("Current heap after: %lu\r\n", heap_stats.current_size);
-    printf("Max heap size after: %lu\r\n", heap_stats.max_size);
+    printf("Post-Free; Current heap: %lu\n", heap_stats.current_size);
+    printf("Post-Free; Max heap size: %lu\n", heap_stats.max_size);
+    
 }