Skip to content

Commit 56ad99f

Browse files
author
Amanda Butler
authored
Merge pull request #696 from deepikabhavnani/trace_fox
Add example link instead hard coded in doc
2 parents cefda5c + e94fd2d commit 56ad99f

File tree

1 file changed

+2
-41
lines changed

1 file changed

+2
-41
lines changed

docs/tutorials/optimize/memory/runtime_stats.md

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,7 @@ Heap statistics provide exact information about the number of bytes dynamically
4848

4949
##### Example program using heap statistics
5050

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)
7552

7653
##### Side effects of enabling heap statistics
7754

@@ -121,20 +98,4 @@ Both of these functions return a struct containing the following:
12198

12299
##### Example program using stack statistics
123100

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

Comments
 (0)