iOS之 FBMemoryProfiler FB的循环引用检测工具
经过两天的google终于搞定了FBMemoryProfiler这个开源检测循环引用的工具。中间的曲折也是让人头疼,言归正传直接说一下这个memoryProfiler
github:https://github.com/chengxiaoyu00/FBMemoryProfiler
1· 先介绍下这个开源工具:
An iOS library providing developer tools for browsing objects in memory over time, using FBAllocationTracker andFBRetainCycleDetector.
基于FBAllocationTracker and FBRetainCycleDetector 开发的一个检测iOS app内存的工具
2· 如何将工具集成到自己的工程:
现在github提供两种方法供开发者使用 :(Carthage 和CocoaPods)
这里我就拿pod说一下,Carthage可以自行google 因为用pod的人比较多集成起来也比较方便
只需要在你工程的podfile中添加:
pod 'FBMemoryProfiler'
然后执行
pod install --verbose --no-repo-update
pod install 估计是不能用啦,因为great wall
3·没什么问题那就到了使用阶段:
使用起来也是很方便的首先在main.m中添加如下代码
#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]));
}
}
然后在appdelegate.m 中添加如下代码
#if DEBUG
NSArray *filters = @[FBFilterBlockWithObjectIvarRelation([UIView class], @"_subviewCache"),
FBFilterBlockWithObjectIvarRelation([UIPanGestureRecognizer class], @"_internalActiveTouches")]; FBObjectGraphConfiguration *configuration =
[[FBObjectGraphConfiguration alloc] initWithFilterBlocks:filters
shouldInspectTimers:NO]; memoryProfiler = [[FBMemoryProfiler alloc] initWithPlugins:@[[CacheCleanerPlugin new],
[RetainCycleLoggerPlugin new]]
retainCycleDetectorConfiguration:configuration];
[memoryProfiler enable];
#endif
还需要引入头文件
#if DEBUG
#import <FBMemoryProfiler/FBMemoryProfiler.h>
#import <FBRetainCycleDetector/FBRetainCycleDetector.h>
#import "CacheCleanerPlugin.h"
#import "RetainCycleLoggerPlugin.h"
#endif
CacheCleanerPlugin.h和
RetainCycleLoggerPlugin.h
我会在下面附带下载地址
好了到目前为止已经可以使用这个工具了具体工具的功能很多大家可以自行开发理解,fb的东西还是良心之作的
这里强调下我的pod版本是最新的,而且你的podfile文件最好按照现在的标准去创建不然可能会提示你pod search 不到FBMenoryProfiler 、 还有这个工具支持版本不能低于8.0 ,到时候启动不了提示你 :dyld: Library not loaded: @rpath/FBAllocationTracker.framework/FBAllocationTracker
Referenced from: / 别怕google一下,具体答案自己去找一下很好改!
下面来一个jif
iOS之 FBMemoryProfiler FB的循环引用检测工具的更多相关文章
- FastJson禁用循环引用检测
我们先来看一个例子: package com.elong.bms; import java.io.OutputStream; import java.util.HashMap; import java ...
- Unity编辑器:基于NGUI的引用检测工具
这里共享一个基于NGUI的引用检测工具.工具包括几个部分:Atlas/Sprite的引用查找:字库引用查找:UITexture引用查找:Component查找: 代码就不多介绍了,文章底部提供源码下载 ...
- 【转】iOS学习之容易造成循环引用的三种场景
ARC已经出来很久了,自动释放内存的确很方便,但是并非绝对安全绝对不会产生内存泄露.导致iOS对象无法按预期释放的一个无形杀手是——循环引用.循环引用可以简单理解为A引用了B,而B又引用了A,双方都同 ...
- iOS - Block产生Memory Leaks循环引用导致的内存泄漏以及解决方案
在ARC(自动引用技术)前,Objective-c都是手动来分配释放 释放 计数内存,其过程非常复杂. ARC技术推出后,貌似世界和平了很多,但是其实ARC并不等同于Java或者C#中的垃圾回收,AR ...
- iOS 内存管理机制和循环引用处理方法
简述 ARC: 自动引用计数, Automatic Reference Counting MRC: Mannul Reference Counting ARC工作原理 1.当每次创建一个新实例时,AR ...
- iOS 性能测试 - FBMemoryProfiler
FBMemoryProfiler 是Facebook开源的一款用于分析iOS内存使用和检测循环引用的工具库. 脑补:http://www.cocoachina.com/ios/20160421/159 ...
- Atitit.json xml 序列化循环引用解决方案json
Atitit.json xml 序列化循环引用解决方案json 1. 循环引用1 2. 序列化循环引用解决方法1 2.1. 自定义序列化器1 2.2. 排除策略1 2.3. 设置序列化层次,一般3级别 ...
- 【FastJSON】解决FastJson中“$ref 循环引用”的问题
0.开发环境 SSH,EasyUI,MySQL 1.需求要求: (1)首先获取所有的贷款订单数据,即List <LoanOrder>. (2)然后从单个贷款订单实体LoanOrder去访问 ...
- Samples DataBind FastJson循环引用问题
Fastjson full support databind, it's simple to use. Encode import com.alibaba.fastjson.JSON; Group g ...
随机推荐
- ES6笔记(3)-- 解构赋值
系列文章 -- ES6笔记系列 解构赋值,即对某种结构进行解析,然后将解析出来的值赋值给相关的变量,常见的有数组.对象.字符串的解构赋值等 一.数组的解构赋值 function ids() { ret ...
- [转载]MongoDB开发学习 经典入门
如果你从来没有接触MongoDB或对MongoDB有一点了解,如果你是C#开发人员,那么你不妨花几分钟看看本文.本文将一步一步带您轻松入门. 阅读目录 一:简介 二:特点 三:下载安装和开启服务器 四 ...
- jdk源码分析之ArrayList
ArrayList关键属性分析 ArrayList采用Object数组来存储数据 /** * The array buffer into which the elements of the Array ...
- C#的变迁史 - C# 5.0 之其他增强篇
1. 内置zip压缩与解压 Zip是最为常用的文件压缩格式之一,也被几乎所有操作系统支持.在之前,使用程序去进行zip压缩和解压要靠第三方组件去支持,这一点在.NET4.5中已有所改观,Zip压缩和解 ...
- 15天玩转redis —— 第八篇 你不得不会的事务玩法
我们都知道redis追求的是简单,快速,高效,在这种情况下也就拒绝了支持window平台,学sqlserver的时候,我们知道事务还算是个比较复杂的东西, 所以这吊毛要是照搬到redis中去,理所当然 ...
- 孙鑫MFC学习笔记18:ActiveX
18 1.容器和服务器程序 2.InvalidateControl重绘控件 3. 4.GetBackColor获取背景色 5.GetForeColor获取前景色 6.TranslateColor进行颜 ...
- Android获取系统时间方法的总结
Android获取系统时间方法的方法有很多种,常用的有Calendar.Date.currentTimeMills等方法. (1)Calendar Calendar获取系统时间首先要用Calendar ...
- django pdb
import pdb; pdb.set_trace() http://charlee.li/debug-djangp-with-pdb.html https://github.com/tomchr ...
- 几个简单的js正则验证
//校验身份证,身份证分为15位和18位 function checkIdCard(obj) { if ((/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.tes ...
- adb 常用命令总结
1. adb / adb -help 使用帮助 2. adb devices 查看连接到电脑的设备 3. adb install example.apk 安装程序 4. adb -s emulator ...
