FballocationTrackerとfbretainCycledetectorを使用して、時間の経過とともにメモリでオブジェクトを閲覧するための開発者ツールを提供するiOSライブラリ。
このライブラリは、 FBAllocationTracker
とFBRetainCycleDetector
どのように協力できるか、実際のアプリでどのように使用できるかを示しています。
FballocationTrackerを使用して、オブジェクトに関する情報を収集します。世代をサポートし、サイクル検出を保持します。
ここに小さなデモがあります(プロジェクトは例のディレクトリで入手できます)
あなたのcartfileに追加:
github "facebook/FBMemoryProfiler"
FBMemoryProfiler
は非bugビルドから構築されているため、テストしたい場合は、
carthage update --configuration Debug
PodSpecに追加:
pod 'FBMemoryProfiler'
FBMemoryProfiler
Debug
ビルドでのみ完全に使用できるようになります。これは、ビルドに提供されて他の構成で機能するように提供できるコンパイルフラグによって制御されます。
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 ];
プラグインは、fbmemoryprofilerpluggableプロトコルに準拠するオブジェクトです。使用法の例:カスタムキャッシュクリーナー、データをサーバーにログに付けるロガー。
支援方法については、寄稿ファイルを参照してください。
参照(ライセンス)