Coder Social home page Coder Social logo

mleakeye's Introduction

MLeakEye

CI Status Version License Platform

需要

最低支持iOS10

安装

通过cocoapods可以直接安装

pod 'MLeakEye', :configurations => ['Debug']

如何使用

第一步:导入框架

#if DEBUG
import MLeakEye
#endif

第二步:开启监听器

#if DEBUG
MLeakEye.shared.open()
#endif

发现有可疑对象泄漏后,会自动有Alert弹窗。

感谢

本仓库是修改了LeakEyeLib的代码,因为和我们的项目库存在冲突,修改了部分代码,感谢

原理

LeakEyeLib基于这样一个假设:

如果Controller被释放了,但其曾经持有过的子对象如果还存在,那么这些子对象就是泄漏的可疑目标。

那么怎么在Controller被释放之后,知道其持有的对象没有被释放呢: 子对象(比如view)建立一个对controller的weak引用,如果Controller被释放,这个weak引用也随之置为nil。那怎么知道子对象没有被释放呢?用一个实例对象每个一小段时间(0.5秒)发出一个ping通知去ping这个子对象,如果子对象还活着就会一个ping通知。所以结论就是:如果子对象的controller已不存在,但还能响应这个ping通知,那么这个对象就是可疑的泄漏对象。

许可证

MIT

mleakeye's People

Contributors

jingyuzhao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.