Memory leaks (-sanitizer-selection memleak)
R2026bEnable detection of memory leaks at runtime
Since R2026b
Description
Specify whether the sanitizer detects memory leaks at runtime. A memory leak occurs when memory is allocated but never freed, leading to increasing memory consumption over time.
Set Option
Set the option using one of these methods:
Polyspace Platform user interface (desktop products only): In your project configuration, on the Testing and Profiling tab, select the Sanitizer node, select Select by category, and then select or clear this option.
Command line: Use the option
-sanitizer-selectionand includememleakin the comma-separated list. See Command-Line Information.Python® API: Set the
MemoryLeakproperty in the testing and profiling configuration. Seepolyspace.project.TestConfiguration.TOML configuration file (
.toml.pscfg) — Use the keyMemoryLeakin the[SanitizerOptions]table. For example:[SanitizerOptions] MemoryLeak = true
Why Use This Option
Use this option to detect memory that is allocated but never freed during test execution. Memory leaks can cause your application to consume increasing amounts of memory over time, eventually leading to resource exhaustion.
Settings
OnThe sanitizer detects memory leaks at runtime.
Off (default)The sanitizer does not detect memory leaks.
Dependencies
This option is available only when you select Select by category as the sanitizer selection mode.
Command-Line Information
The command-line workflow for setting this option depends on your workflow.
If you build your source and tests using a Polyspace Platform Project — Once you set this option in the project using the Polyspace Platform user interface, you cannot override or modify this option using the
polyspace-testcommand.If you build your sources and xUnit tests using your own toolchain — Specify this option to the
polyspace-code-profilercommand.
Parameter: -sanitizer-selection |
Value: Include memleak in comma-separated list of error categories |
| Default: off |
Example:
polyspace-code-profiler -instrument -instrum-dir |
Version History
Introduced in R2026b