JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C#


CSHARP.ALLOC.LEAK.NOTSTORED : Closeable Not Stored (C#)

要旨

A closeable has not been immediately stored into a local variable.

The garbage collector automatically releases the memory allocated to a managed object when that object is no longer used. However, it is not possible to predict when garbage collection will occur. Furthermore, the garbage collector has no knowledge of unmanaged resources (such as database, streams, open files, etc.). For these reasons, they should be disposed, or otherwise the system might run into an out of resource exception. The dispose operation should always be performed, in every execution path. For this reason, the using or finally constructs should be used.

This checker verifies that resources are always released after being open, for every execution path. This checker recognizes and accepts as correct code where a resource is stored into a field or returned from a method and is then closed at the end, at least for some frequent scenarios.

プロパティ

クラス名 Closeable Not Stored (C#)
日本語クラス名 Closeable Not Stored (C#)
クラス分類 信頼性 (reliability)
ニーモニック CSHARP.ALLOC.LEAK.NOTSTORED
カテゴリー
CWE CWE:400 Uncontrolled Resource Consumption
対応言語 C# で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Closeable Not Stored (C#)"

解決法

Guarantee that all resources are released, typically by using a using or a finally construct. In general, avoid storing resources into fields or returning resources from methods or letting a method close a resource passed to it as a parameter.

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。

 

To report problems with this documentation, please visit https://support.codesecure.com/.