Skip to content

add memory trace example #88

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 1 commit into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions APIs_Platform/Memory_tracing_ex_1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Memory tracing trace example

Example to demonstrate memory trace functionality in Mbed OS
23 changes: 23 additions & 0 deletions APIs_Platform/Memory_tracing_ex_1/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2020 Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdlib.h>
#include "mbed.h"
#include "mbed_mem_trace.h"


int main()
{
mbed_mem_trace_set_callback(mbed_mem_trace_default_callback);
while (true) {
void *p = malloc(50);
printf("50B allocated at %p\n", p);

ThisThread::sleep_for(500);

free(p);
printf("50B freed at %p\n\n", p);
}
}
3 changes: 3 additions & 0 deletions APIs_Platform/Memory_tracing_ex_1/mbed_app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"macros": ["MBED_MEM_TRACING_ENABLED=1"]
}