_C_Quickpool_Report ()- 產生快速儲存區記憶體管理程式報告

格式

#include <stdlib.h>
void _C_Quickpool_Report(void);

語言層次

擴充

安全執行緒

說明

_C_Quickpool_Report() 函數會產生排存檔,其中包含現行啟動群組中「快速儲存區」記憶體管理程式所使用記憶體的 Snapshot。 如果尚未啟用現行啟動群組的「快速儲存區」記憶體管理程式,或尚未啟用統計資料收集,則報告將會是一則訊息,指出未收集任何資料。

如果已啟用「快速儲存區」記憶體管理程式,且已啟用統計資料收集,則產生的報告會指出在啟用統計資料收集期間,每 16 個位元組記憶體的配置嘗試次數。 此外,此報告指出針對每一個儲存區達到的未完成配置 (尖峰配置) 數目上限。 如果未對給定的記憶體範圍提出儲存體要求,則該記憶體範圍將不會併入報告中。 對於大於資料格大小上限 (4096 個位元組) 的配置,不會產生任何輸出。

回覆值

函數沒有回覆值。

範例

下列範例使用 _C_Quickpool_Init() 來啟用「快速儲存區」記憶體管理程式。 它使用 _C_COLLECT_STATS 旗標來收集資訊。 收集的資訊會使用 _C_Quickpool_Report()來列印。
#include <stdlib.h>
#include <stdio.h>
int main(void) {
  char *p;
  int   i;
  unsigned int cell_sizes[2]       = { 16, 64 };
  unsigned int cells_per_extent[2] = { 16, 16 };
  _C_Quickpool_Debug_T  dbgVals = { _C_COLLECT_STATS, 'A', 'B' };

  if (_C_Quickpool_Init(2, cell_sizes, cells_per_extent) {
    printf("Error initializing Quick Pool memory manager.\n");
    return -1;
  }

  _C_Quickpool_Debug(&dbgVals);

  for (i = 1; i <= 64; i++) {
    p = malloc(i);
    free(p);
  }
  p = malloc(128);
  free(p);
  _C_Quickpool_Report();
  return 0;
}
/*****************Spooled File Output should be similar to:**********
Pool 1 (16 bytes, 1 peak allocations):
1-16 bytes: 16 allocations
Pool 2 (64 bytes, 1 peak allocations):
17-32 bytes: 16 allocations
33-48 bytes: 16 allocations
49-64 bytes: 16 allocations
Remaining allocations smaller than the largest cell size (4096 bytes):
113-128 bytes: 1 allocations
*******************************************************************/

相關資訊