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的对象。示例用法:自定义缓存清洁器,将数据记录到服务器的记录器。
有关如何提供帮助,请参见贡献文件。
请参阅(许可证)