Skip to content

Add example link instead hard coded in doc #696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 2 additions & 41 deletions docs/tutorials/optimize/memory/runtime_stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,7 @@ Heap statistics provide exact information about the number of bytes dynamically

##### Example program using heap statistics

```
#include "mbed.h"
#include "mbed_stats.h"

int main(void)
{
mbed_stats_heap_t heap_stats;

printf("Starting heap stats example\r\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);

free(allocation);

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);
}
```
[![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)

##### Side effects of enabling heap statistics

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

##### Example program using stack statistics

```
#include "mbed.h"
#include "mbed_stats.h"

int main(void)
{
printf("Starting stack stats example\r\n");

int cnt = osThreadGetCount();
mbed_stats_stack_t *stats = (mbed_stats_stack_t*) malloc(cnt * sizeof(mbed_stats_stack_t));

cnt = mbed_stats_stack_get_each(stats, cnt);
for (int i = 0; i < cnt; i++) {
printf("Thread: 0x%X, Stack size: %u, Max stack: %u\r\n", stats[i].thread_id, stats[i].reserved_size, stats[i].max_size);
}
}
```
[![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)