FBMemoryProfiler
0.1.2
一個iOS庫,使用FallocationTracker和fbretainCycleDetector為隨著時間的推移在內存中瀏覽對象的開發人員工具。
該圖書館顯示了FBAllocationTracker
和FBRetainCycleDetector
如何合作,以及如何在真實應用中使用它們。
它使用FallocationTracker收集有關對象的信息。它支持幾代人並保留週期檢測。
這是一個小型演示(示例目錄中可用項目)
向您的卡特菲勒添加:
github "facebook/FBMemoryProfiler"
FBMemoryProfiler
是由非吊帶構建構建的,因此,當您要測試時,請使用
carthage update --configuration Debug
向您的podspec添加:
pod 'FBMemoryProfiler'
您只能在Debug
構建中完全使用FBMemoryProfiler
。這是由可以提供給構建的彙編標誌來控制的,以使其在其他配置中起作用。
要開始使用FBMemoryProfiler
您首先需要啟用FBAllocationTracker
。
# import < FBAllocationTracker/FBAllocationTrackerManager.h >
int main ( int argc, char * argv[]) {
[[FBAllocationTrackerManager sharedManager ] startTrackingAllocations ];
[[FBAllocationTrackerManager sharedManager ] enableGenerations ];
@autoreleasepool {
return UIApplicationMain (argc, argv, nil , NSStringFromClass ([AppDelegate class ]));
}
}
啟用內存剖面:
# import < FBMemoryProfiler/FBMemoryProfiler.h >
FBMemoryProfiler *memoryProfiler = [FBMemoryProfiler new ];
[memoryProfiler enable ];
// Store memory profiler somewhere to extend it's lifetime
_memoryProfiler = memoryProfiler;
FBMemoryProfiler
將顯示為屏幕上的按鈕。一旦敲擊,它將在全尺寸模式下打開內存剖面。
我們還可以定義插件(在下面的檢查)和保留週期檢測器的過濾器,並將其傳遞給配置。
_memoryProfiler = [[FBMemoryProfiler alloc ] initWithPlugins: @[[IncredibleCacheCleaningPlugin new ],
[AwesomeLoggerPlugin new ]]
retainCycleDetectorConfiguration: someConfigurationWithCustomFilters];
[_memoryProfiler enable ];
插件是符合FBMemoryProfilerPlugg的對象。示例用法:自定義緩存清潔器,將數據記錄到服務器的記錄器。
有關如何提供幫助,請參見貢獻文件。
請參閱(許可證)