メモリー使用状況検査は、使用中のヒープメモリーすべてを確認することができます。この情報によって、プログラムのどこでメモリーが割り当てられたか、またはどのプログラムセクションが大半の動的メモリーを使用しているかを知ることができます。この情報は、プログラムの動的メモリー消費を削減するためにも有効であり、パフォーマンスの向上に役立ちます。
メモリー使用状況検査は、パフォーマンス向上または仮想メモリーの使用制御に役立ちます。プログラムが終了したら、メモリー使用状況レポートを生成できます。メモリー使用情報は、メモリーの使用状況を表示させるコマンド (showmemuse) を使用して、プログラムの実行中に随時取得することもできます。詳細については、「showmemuse コマンド」を参照してください。
メモリー使用状況検査をオンにすると、リーク検査もオンになります。プログラム終了時のリークレポートに加えて、使用中ブロック (biu) レポートも得ることができます。デフォルトでは、使用中ブロックの簡易レポートがプログラムの終了時に生成されます。メモリー使用状況レポートの詳細を制御するには、dbx 環境変数 rtc_biu_at_exit (「dbx 環境変数の設定」 を参照) を使用します。
次に、典型的な簡易メモリー使用状況レポートを示します。
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 コマンドを使用すると、メモリー使用状況レポートをいつでも要求できます。