メモリー使用状況検査を使用すると、使用中のすべてのヒープメモリーを表示できます。この情報によって、プログラムのどこでメモリーが割り当てられたか、またはどのプログラムセクションが大半の動的メモリーを使用しているかを知ることができます。この情報はまた、プログラムの動的なメモリー消費の削減にも役立つほか、パフォーマンスチューニングにも役立つ可能性があります。
メモリー使用状況検査は、パフォーマンス向上または仮想メモリーの使用制御に役立ちます。プログラムが終了したら、メモリー使用状況レポートを生成できます。メモリー使用状況の情報はまた、メモリー使用状況を表示させる showmemuse コマンドを使用して、プログラムの実行中にいつでも取得できます。 詳細については、showmemuse コマンドを参照してください。
メモリー使用状況検査を有効にすると、リーク検査も有効になります。プログラム終了時のリークレポートに加えて、「使用中のブロック」(biu) レポートも取得されます。デフォルトでは、使用中のブロックの簡易レポートがプログラム終了時に生成されます。メモリー使用状況レポート内の詳細レベルは、dbxenv 変数 rtc_biu_at_exit によって制御されます。
次の例は、標準的なメモリー使用状況の簡易レポートを示しています。
Blocks in use report (blocks in use: 5 total size: 40 bytes) Total % of Num of Avg Allocation call stack Size All Blocks Size ========== ==== ====== ====== ===================================== 16 40% 2 8 nonleak < nonleak 8 20% 1 8 nonleak < main 8 20% 1 8 cyclic_leaks < main 8 20% 1 8 cyclic_leaks < main
Blocks in use report (blocks in use: 5 total size: 40 bytes) Block in use (biu): Found 2 blocks totaling 16 bytes (40.00% of total; avg block size 8) At time of each allocation, the call stack was: [1] nonleak() at line 182 in "memuse.c" [2] nonleak() at line 185 in "memuse.c" Block in use (biu): Found block of size 8 bytes at address 0x21898 (20.00% of total) At time of allocation, the call stack was: [1] nonleak() at line 182 in "memuse.c" [2] main() at line 74 in "memuse.c" Block in use (biu): Found block of size 8 bytes at address 0x21958 (20.00% of total) At time of allocation, the call stack was: [1] cyclic_leaks() at line 154 in "memuse.c" [2] main() at line 118 in "memuse.c" Block in use (biu): Found block of size 8 bytes at address 0x21978 (20.00% of total) At time of allocation, the call stack was: [1] cyclic_leaks() at line 155 in "memuse.c" [2] main() at line 118 in "memuse.c" The following is the corresponding verbose memory use report:
showmemuse コマンドを使用すると、メモリー使用状況レポートをいつでも要求できます。