Skip to content

Commit 34c6463

Browse files
author
Amanda Butler
authored
Merge pull request #694 from deepikabhavnani/trace_fix
Add overhead info for memory trace / stats
2 parents a5e51e3 + 8548387 commit 34c6463

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

docs/reference/api/platform/MbedStats.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ You can use memory statistics functions to capture heap usage, cumulative stack
99
- `MBED_HEAP_STATS_ENABLED`.
1010
- `MBED_STACK_STATS_ENABLED`.
1111

12+
<span class="notes">**Note:** Each `malloc` or `calloc` memory allocation call adds an overhead of 8 bytes when heap memory statistics are enabled.</span>
13+
1214
### Thread statistics
1315

1416
You can use the thread statistics function `mbed_stats_thread_get_each` to capture the thread ID, state, priority, name and stack information for all active threads at runtime. To enable thread monitoring, you must build Mbed OS with the `MBED_THREAD_STATS_ENABLED` macro.

docs/reference/api/platform/MemTrace.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ You must enable the `memory-tracing-enabled` setting in the Mbed OS platform con
1616

1717
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`.
1818

19+
<span class="notes">**Note:** Each `malloc` or `calloc` memory allocation call adds an overhead of 8 bytes when heap memory statistics are enabled.</span>
20+
1921
For a step-by-step guide about how to use optimize memory using runtime memory tracing, please see our [runtime memory tracing tutorial](/docs/development/tutorials/optimizing.html#runtime-memory-tracing).
2022

2123
### Memory tracing functions reference

docs/tutorials/optimize/memory/runtime_mem_trace.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ It outputs the following trace:
6262

6363
- The tracer doesn't handle nested calls of the memory functions. For example, if you call `realloc` and the implementation of `realloc` calls `malloc` internally, the call to `malloc` is not traced.
6464
- The **caller** argument of the callback function isn't always reliable. It doesn't work at all on some toolchains, and it might output erroneous data on others.
65+
- Overhead of 8 bytes is added to every dynamic memory allocation when memory tracing is enabled.

0 commit comments

Comments
 (0)