Test Profile App ASAN/LSAN
Detect Runtime Memory Leaks with Leak Sanitizer
NoteBefore you run the Leak Sanitizer, follow the steps below:
- Make sure that you have an Emulator or a connected target device running
- If you want to try out the tool and do not have an applicable project to test, create a test project with the Project Wizard using a template or a sample. For more information on creating a project, see Create Tizen Native Application
To use the Leak Sanitizer, follow the steps below:
-
In the Project Explorer view, select Tools > Tizen > Profiler > Profile With Leak Sanitizer.
The profiler links your program to a runtime library containing the bare necessities required for Leak Sanitizer to work, this is done by setting the option
-fsanitize
toleak
, and no compile-time instrumentation is applied here. Whilst the option is set, the application launches on the connected target device or the Emulator to detect any runtime memory leaks. As illustrated in the following figure: -
After the application launches, run the application scenario that you want to test. Unlike the Address Sanitizer, Visual Studio Code checks and shows the profiling result when you exit the application. As illustrated in the following figure:
After clicking the Stop Profiling button, VS Code will collect and show the profiling report. As illustrated in the following figure:
Detect Runtime Memory Errors with Address Sanitizer
NoteBefore you run the Address Sanitizer, follow the steps below:
- Make sure that you have an Emulator or a connected target device running
- If you want to try out the tool but do not have an applicable project to test, create a test project with the Project Wizard using a template or a sample. For more information on creating a project, see Create Tizen Native Application
To use the Address Sanitizer, follow the steps below:
-
In the Project Explorer view, select Tools > Tizen > Profiler > Profile With Address Sanitizer.
The profiling instruments the code and compiles the project for the Address Sanitizer. Finally, it launches the application on the connected target or Emulator. As illustrated in the following figure:
-
If there is any memory error, Visual Studio Code shows the profiling result as illustrated in the following figure:
In the example shown in the figure, the application crashes as soon as it is launched because the memory corruption happens in the
main()
function.