6 つの新しい Discover API がコード分析ツールに追加されました。アプリケーションが使用しているメモリーが多すぎる場合は、これらの API を使用して、アプリケーションが終了する前にメモリーリークが発生する場所を特定することができます。また、API を使用して、使用中のメモリーブロックをすべて検索できます。
これらの API は、アプリケーションソースに直接挿入したりデバッグセッション中に呼び出したりして、任意の開始点からの新規および合計のメモリー使用量や新規および合計のメモリーリークをいつでも報告することができます。特に、長時間実行または常時実行のエンタープライズサーバーアプリケーションで役立ちます。
次の API がコード分析ツールに追加されました。
discover_report_all_inuse()
discover_mark_all_inuse_as_reported()
discover_report_unreported_inuse()
discover_report_all_leaks()
discover_mark_all_leaks_as_reported()
discover_report_unreported_leaks()
次は、discover_report_unreported_leaks() API を使用する例です (Discover でバイナリを実行してから dbx を使用してこの API を実行しています)。
%discover -w - a.out % dbx a.out (dbx) stop in foo2 (dbx) run (dbx) call discover_report_unreported_leaks() ******** discover_report_unreported_leaks() Report ******** 1 allocation at 1 location left on the heap with a total size of 1 byte LEAK 1: 1 allocation with total size of 1 byte foo1() + 0x5e <api_example.c:7> 4: #include <discoverAPI.h> 5: 6: void foo1() { 7:=> char *x = (char *) malloc(sizeof(char)); 8: *x = 'a'; 9: printf("x = %c\n", *x); 10: /*free(x);*/ main() + 0x1a <api_example.c:21> 18: } 19: 20: int main() { 21:=> foo1(); 22: foo2(); 23: return 0; 24: } _start() + 0x71 **********************************************************
各 Discover API の詳細と、その使用方法については、Discover のヘッダーファイルおよびOracle Solaris Studio 12.4: Discover および Uncover ユーザーズガイド のdiscover APIを参照してください。