@@ -48,30 +48,7 @@ Heap statistics provide exact information about the number of bytes dynamically
48
48
49
49
##### Example program using heap statistics
50
50
51
- ```
52
- #include "mbed.h"
53
- #include "mbed_stats.h"
54
-
55
- int main(void)
56
- {
57
- mbed_stats_heap_t heap_stats;
58
-
59
- printf("Starting heap stats example\r\n");
60
-
61
- void *allocation = malloc(1000);
62
- printf("Freeing 1000 bytes\r\n");
63
-
64
- mbed_stats_heap_get(&heap_stats);
65
- printf("Current heap: %lu\r\n", heap_stats.current_size);
66
- printf("Max heap size: %lu\r\n", heap_stats.max_size);
67
-
68
- free(allocation);
69
-
70
- mbed_stats_heap_get(&heap_stats);
71
- printf("Current heap after: %lu\r\n", heap_stats.current_size);
72
- printf("Max heap size after: %lu\r\n", heap_stats.max_size);
73
- }
74
- ```
51
+ [ ![ View code] ( https://www.mbed.com/embed/?url=https://os.mbed.com/teams/mbed_example/code/heap_stats_example/ )] ( https://os.mbed.com/teams/mbed_example/code/heap_stats_example/file/c084f1df237e/main.cpp )
75
52
76
53
##### Side effects of enabling heap statistics
77
54
@@ -121,20 +98,4 @@ Both of these functions return a struct containing the following:
121
98
122
99
##### Example program using stack statistics
123
100
124
- ```
125
- #include "mbed.h"
126
- #include "mbed_stats.h"
127
-
128
- int main(void)
129
- {
130
- printf("Starting stack stats example\r\n");
131
-
132
- int cnt = osThreadGetCount();
133
- mbed_stats_stack_t *stats = (mbed_stats_stack_t*) malloc(cnt * sizeof(mbed_stats_stack_t));
134
-
135
- cnt = mbed_stats_stack_get_each(stats, cnt);
136
- for (int i = 0; i < cnt; i++) {
137
- printf("Thread: 0x%X, Stack size: %u, Max stack: %u\r\n", stats[i].thread_id, stats[i].reserved_size, stats[i].max_size);
138
- }
139
- }
140
- ```
101
+ [ ![ View code] ( https://www.mbed.com/embed/?url=https://os.mbed.com/teams/mbed_example/code/stack_stats_example/ )] ( https://os.mbed.com/teams/mbed_example/code/stack_stats_example/file/539750137652/main.cpp )
0 commit comments