AUTOSAR C++14 Rule A18-5-7
If non-real-time implementation of dynamic memory management functions is used in the project, then memory shall only be allocated and deallocated during non-real-time program phases
Since R2022a
Description
Rule Definition
If non-real-time implementation of dynamic memory management functions is used in the project, then memory shall only be allocated and deallocated during non-real-time program phases.
Rationale
A real-time function is one with a known worst case execution time. That is, the execution time of real-time functions cannot exceed a specific and known value.
Inside a real-time function, you might be using functions that manage dynamic memory,
        such as new or delete. The execution time of these
        functions depends on how much memory the functions manage. Because their worst case
        execution time is not deterministic, using these functions in the real time phase of the
        application might result in unexpected behaviors, memory leaks, and memory fragmentation.
        Dynamic memory management in real time requires implementing deterministic implementations
        of these functions that have a known worst case execution time.
Avoid using non-real-time dynamic memory management functions in the real time phase of your application. Perform non-real-time memory operations in the non-real-time phase such as the initialization or the non-real-time state transitions.
Polyspace Implementation
To check for violations of this rule, specify your real-time functions by using the
        analysis option -code-behavior-specifications. In the
        code behavior specification XML file, specify a function as a real-time function by using
        the behavior REAL_TIME_FUNC. Polyspace® flags a specified real-time function if :
- The function allocates or deallocates dynamic memory by using a non-real-time implementation. 
- The function calls a function that uses non-real-time dynamic memory management. 
Polyspace assumes that these functions from the standard library use non-real-time implementation of dynamic memory management:
- The operators - newand- delete.
- std::make_unique()
- std::vector::vector()
- std::vector::reserve()
- std::basic_string::basic_string()
You might use other functions in your code that use non-real-time
        implementation of dynamic memory management. Specify these functions as non-real-time
        dynamic memory management function by using the behavior
        MANAGES_MEMORY.
To use this rule, specify at least one entry that has the behavior
          REAL_TIME_FUNC. If you use this checker without specifying the code
        behavior, Polyspace produces a warning.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
| Group: Language support library | 
| Category: Required, Non-automated | 
Version History
Introduced in R2022a