Skip to content

Move mem_tracing from macro setting to using the MbedOS Config Settings #684

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
Show file tree
Hide file tree
Changes from 3 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
14 changes: 12 additions & 2 deletions docs/reference/api/platform/MemTrace.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

Mbed OS provides a set of functions that you can use to study the runtime memory allocation pattern of your software: which sections of the code allocate and free memory and how much memory they need.

You must define the `MBED_MEM_TRACING_ENABLED` macro to enable memory tracing.
You must enable the `memory-tracing-enabled` setting in the Mbed OS platform configuration options to enable memory tracing. The recommended way to enable this setting is to add it to your `mbed_app.json`:

```
{
"target_overrides": {
"*": {
"platform.memory-tracing-enabled": true
}
}
}
```

You can use the `mbed_mem_trace_set_callback` API to set the callback for memory tracing. The callback is invoked every time you call standard allocation functions, such as `malloc`, `realloc`, `calloc` and `free`.

Expand All @@ -16,6 +26,6 @@ For a step-by-step guide about how to use optimize memory using runtime memory t

[![View code](https://www.mbed.com/embed/?url=https://os.mbed.com/teams/mbed_example/code/memory_tracing_example/)](https://os.mbed.com/teams/mbed_example/code/memory_tracing_example/file/168ab14e6694/main.cpp)

### Related content
### Related content

- [Runtime memory tracing tutorial](/docs/development/tutorials/optimizing.html#runtime-memory-tracing).
8 changes: 6 additions & 2 deletions docs/tutorials/optimize/memory/runtime_mem_trace.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ Running out of memory is a common problem with resource constrained systems such

#### Using the memory tracer

The memory tracer is not enabled by default. To enable it, you need to define the **`MBED_MEM_TRACING_ENABLED`** macro. The recommended way to define this macro is to add it to the list of macros defined in your `mbed_app.json`:
The memory tracer is not enabled by default. To enable it, you need to enable the **`memory-tracing-enabled`** setting in the Mbed OS platform configuration options. The recommended way to enable this setting is to add it to your `mbed_app.json`:

```
{
"macros": ["MBED_MEM_TRACING_ENABLED"]
"target_overrides": {
"*": {
"platform.memory-tracing-enabled": true
}
}
}
```

Expand Down