fballocationTracker 및 fbretaincycledetector를 사용하여 시간이 지남에 따라 메모리에서 개체를 탐색하기위한 개발자 도구를 제공하는 iOS 라이브러리.
이 라이브러리는 FBAllocationTracker
및 FBRetainCycleDetector
함께 협력 할 수있는 방법과 실제 앱에서 어떻게 사용될 수 있는지 보여줍니다.
fballocationTracker를 사용하여 객체에 대한 정보를 수집합니다. 세대를 지원하고 사이클 탐지를 유지합니다.
다음은 작은 데모입니다 (프로젝트는 예제 디렉토리에서 사용할 수 있음)
Cartfile에 추가 :
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 ];
플러그인은 FBMEMORYPROFILERPLUGGABLE PROTOCOL을 준수하는 객체입니다. 예제 사용 : 사용자 정의 캐시 클리너, 데이터를 서버에 로그인하는 로거.
도움이되는 방법은 기여 파일을 참조하십시오.
(라이센스) 참조