GithubHelp home page GithubHelp logo

circle's Introduction

Circle - a cycle collector for Objective-C ARC

Circle is a highly experimental cycle collector for Objective-C programs compiled with ARC. It is by no means complete, let alone production-ready. It is, however, really cool. Your contributions, should you choose to make any, would be most welcome.

Quick Source Code Tour

Circle is divided into two parts. The first part is responsible for detecting the locations of strong references within an object, and is contained in CircleIvarLayout. It exposes the EnumerateStrongReferences function which is used by the collector to walk the object graph.

The second part is the cycle collector, and is located in CircleSimpleCycleFinder.

API Use

Did you notice the part above where I mentioned this is incomplete and not production-ready? Because this code is totally incomplete and not production-ready.

That said, you can use it for some stuff. The first thing you want to do is create a collector:

CircleSimpleCycleFinder *collector = [[CircleSimpleCycleFinder alloc] init];

Next, add some candidate objects to it. The collector does not search the entire object graph automatically. Rather, it searches the graph starting from candidate objects that you explicitly give to it.

[collector addCandidate: myObj];
[collector addCandidate: otherObj];

Next, you can run a collection cycle:

[collector collect];

This will search for leaked object cycles involving the candidates and break them by zeroing out the strong references located within the candidate objects.

It's also possible to have the collector walk the graph and gather info about it without actually performing any collection:

NSArray *infoArrays = [collector objectInfos];

The result is an array of arrays containing instances of CircleObjectInfo:

for(NSArray *infos in infoArrays)
    for(CircleObjectInfo *info in infos)
        if([info leaked])
            NSLog(@"Found a leaked object: %@", [info object]);

The CircleObjectInfo class contains various information about each object that was traversed, including its address, whether it is externally referenced (has retains that can't be accounted for by the traversed cycle), whether it's part of a cycle at all, whether it's leaked (no object in the cycle is externally referenced), the objects within the cycle that refer to this object, and the locations of their strong references.

License

Circle is made available under a BSD license. See the LICENSE file for the actual license text.

circle's People

Contributors

mikeash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

circle's Issues

How dispose_helper work

I want to konw how dispose_helper work to release object, can you explain to me, or give me a link. Thank you!

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.