经过两天的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的循环引用检测工具的更多相关文章

  1. FastJson禁用循环引用检测

    我们先来看一个例子: package com.elong.bms; import java.io.OutputStream; import java.util.HashMap; import java ...

  2. Unity编辑器:基于NGUI的引用检测工具

    这里共享一个基于NGUI的引用检测工具.工具包括几个部分:Atlas/Sprite的引用查找:字库引用查找:UITexture引用查找:Component查找: 代码就不多介绍了,文章底部提供源码下载 ...

  3. 【转】iOS学习之容易造成循环引用的三种场景

    ARC已经出来很久了,自动释放内存的确很方便,但是并非绝对安全绝对不会产生内存泄露.导致iOS对象无法按预期释放的一个无形杀手是——循环引用.循环引用可以简单理解为A引用了B,而B又引用了A,双方都同 ...

  4. iOS - Block产生Memory Leaks循环引用导致的内存泄漏以及解决方案

    在ARC(自动引用技术)前,Objective-c都是手动来分配释放 释放 计数内存,其过程非常复杂. ARC技术推出后,貌似世界和平了很多,但是其实ARC并不等同于Java或者C#中的垃圾回收,AR ...

  5. iOS 内存管理机制和循环引用处理方法

    简述 ARC: 自动引用计数, Automatic Reference Counting MRC: Mannul Reference Counting ARC工作原理 1.当每次创建一个新实例时,AR ...

  6. iOS 性能测试 - FBMemoryProfiler

    FBMemoryProfiler 是Facebook开源的一款用于分析iOS内存使用和检测循环引用的工具库. 脑补:http://www.cocoachina.com/ios/20160421/159 ...

  7. Atitit.json xml 序列化循环引用解决方案json

    Atitit.json xml 序列化循环引用解决方案json 1. 循环引用1 2. 序列化循环引用解决方法1 2.1. 自定义序列化器1 2.2. 排除策略1 2.3. 设置序列化层次,一般3级别 ...

  8. 【FastJSON】解决FastJson中“$ref 循环引用”的问题

    0.开发环境 SSH,EasyUI,MySQL 1.需求要求: (1)首先获取所有的贷款订单数据,即List <LoanOrder>. (2)然后从单个贷款订单实体LoanOrder去访问 ...

  9. Samples DataBind FastJson循环引用问题

    Fastjson full support databind, it's simple to use. Encode import com.alibaba.fastjson.JSON; Group g ...

随机推荐

  1. TinyOS和Deluge的安装模拟(二)

    TinyOS的安装 TinyOS的安装是一件麻烦的事情,它不像其他的开发环境那样配置简单.要想成功安装好TinyOS,需要选择好PC操作系统,TinyOS安装文件的版本,工具链的版本…….总之,安装过 ...

  2. 【转载】Lucene.Net入门教程及示例

    本人看到这篇非常不错的Lucene.Net入门基础教程,就转载分享一下给大家来学习,希望大家在工作实践中可以用到. 一.简单的例子 //索引Private void Index(){    Index ...

  3. DES加密解密

    加密后生成Base64字符串,并去除'='字符. 加密后替换掉'+',这样加密后的字符串可以作为url参数传递. using System; using System.IO; using System ...

  4. C#遍历Dictionary

    C#遍历Dictionary方法 Dictionary<string, int> d = new Dictionary<string, int>(); foreach (Key ...

  5. Sql Server中常见的数据类型

    转至http://www.cnblogs.com/andy_tigger/archive/2011/08/21/2147745.html bit    整型 bit数据类型是整型,其值只能是0.1或空 ...

  6. SQL查询中in、exists、not in、not exists的用法与区别

    1.in和exists in是把外表和内表作hash(字典集合)连接,而exists是对外表作循环,每次循环再对内表进行查询.一直以来认为exists比in效率高的说法是不准确的,如果查询的两个表大小 ...

  7. 孙鑫MFC学习笔记20:Hook编程

    1.HOOK拦截消息,设置越后的钩子优先级越高(钩子队列)2.SetWindowHookEx设置钩子    如果thread identifier为0或其他进程创建的线程,回调函数需要在动态链接库中声 ...

  8. error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.

    error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCom ...

  9. javamail 利用qq邮箱做邮箱服务器,简单小demo

    首先maven: <dependency> <groupId>javax.mail</groupId> <artifactId>mail</art ...

  10. python问题记录

    今天才python群里看到一个问题 python2.7: L = [x for x in 'hello'] print L print x python3.4: L = [ x for x in 'h ...