|
1 | 1 | ---
|
2 |
| -description: "Learn more about: C6014" |
3 |
| -title: C6014 |
4 |
| -ms.date: 11/04/2016 |
| 2 | +description: "Learn more about: Warning C6014" |
| 3 | +title: Warning C6014 |
| 4 | +ms.date: 10/03/2022 |
5 | 5 | ms.topic: reference
|
6 |
| -f1_keywords: ["C6014"] |
| 6 | +f1_keywords: ["C6014", "MEMORY_LEAK", "__WARNING_MEMORY_LEAK"] |
7 | 7 | helpviewer_keywords: ["C6014"]
|
8 | 8 | ms.assetid: ef76ec88-74d2-4a3b-b6fe-4b0851ab3372
|
9 | 9 | ---
|
10 |
| -# C6014 |
| 10 | +# Warning C6014 |
11 | 11 |
|
12 | 12 | > warning C6014: Leaking memory.
|
13 | 13 |
|
14 |
| -This warning indicates that the specified pointer points to allocated memory or some other allocated resource that has not been freed. The analyzer checks for this condition only when the `_Analysis_mode_(_Analysis_local_leak_checks_)` SAL annotation is specified. By default, this annotation is specified for Windows kernel mode (driver) code. For more information about SAL annotations, see [Using SAL Annotations to Reduce C/C++ Code Defects](../code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects.md). |
| 14 | +This warning indicates that the specified pointer points to allocated memory or some other allocated resource that hasn't been freed. |
| 15 | + |
| 16 | +## Remarks |
| 17 | + |
| 18 | +The analyzer checks for this condition only when the `_Analysis_mode_(_Analysis_local_leak_checks_)` SAL annotation is specified. By default, this annotation is specified for Windows kernel mode (driver) code. For more information about SAL annotations, see [Using SAL Annotations to Reduce C/C++ Code Defects](../code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects.md). |
15 | 19 |
|
16 | 20 | ## Examples
|
17 | 21 |
|
18 |
| -The following code generates this warning: |
| 22 | +The following code generates warning C6014: |
19 | 23 |
|
20 | 24 | ```cpp
|
21 | 25 | // cl.exe /analyze /EHsc /nologo /W4
|
@@ -72,11 +76,11 @@ int main( )
|
72 | 76 | }
|
73 | 77 | ```
|
74 | 78 |
|
75 |
| -This warning is reported for both memory and resource leaks when the resource is commonly *aliased* to another location. Memory is aliased when a pointer to the memory escapes the function by means of an `_Out_` parameter annotation, global variable, or return value. This warning can be reported on function exit if the argument is annotated as having been expected to be released. |
| 79 | +This warning is reported for both memory and resource leaks when the resource is commonly *aliased* to another location. Memory is aliased when a pointer to the memory escapes the function by using an `_Out_` parameter annotation, global variable, or return value. This warning can be reported on function exit if the argument is annotated that its release is expected. |
76 | 80 |
|
77 |
| -Note that Code Analysis will not recognize the actual implementation of a memory allocator (involving address arithmetic) and will not recognize that memory is allocated (although many wrappers will be recognized). In this case, the analyzer does not recognize that the memory was allocated and issues this warning. To suppress the false positive, use a `#pragma` directive on the line that precedes the opening brace `{` of the function body. |
| 81 | +Code Analysis won't recognize the actual implementation of a memory allocator (involving address arithmetic) and won't recognize that memory is allocated (although many wrappers will be recognized). In this case, the analyzer doesn't recognize that the memory was allocated and issues this warning. To suppress the false positive, use a `#pragma` directive on the line that precedes the opening brace `{` of the function body. |
78 | 82 |
|
79 |
| -To avoid these kinds of potential leaks altogether, use the mechanisms that are provided by the C++ Standard Template Library (STL). These include [shared_ptr](../standard-library/shared-ptr-class.md), [unique_ptr](../standard-library/unique-ptr-class.md), and [vector](../standard-library/vector.md). For more information, see [Smart Pointers](../cpp/smart-pointers-modern-cpp.md) and [C++ Standard Library](../standard-library/cpp-standard-library-reference.md). |
| 83 | +To avoid these kinds of potential leaks altogether, use the mechanisms that are provided by the C++ Standard Library (STL). These include [`shared_ptr`](../standard-library/shared-ptr-class.md), [`unique_ptr`](../standard-library/unique-ptr-class.md), and containers such as [`vector`](../standard-library/vector.md). For more information, see [Smart pointers](../cpp/smart-pointers-modern-cpp.md) and [C++ Standard Library](../standard-library/cpp-standard-library-reference.md). |
80 | 84 |
|
81 | 85 | ```cpp
|
82 | 86 | // cl.exe /analyze /EHsc /nologo /W4
|
@@ -110,4 +114,4 @@ int main( )
|
110 | 114 |
|
111 | 115 | ## See also
|
112 | 116 |
|
113 |
| -[C6211](../code-quality/c6211.md) |
| 117 | +[Warning C6211](../code-quality/c6211.md) |
0 commit comments