Skip to content

Commit

Permalink
Merge pull request #49 from Megra/remove-dead-cycles
Browse files Browse the repository at this point in the history
Remove dead cycles
  • Loading branch information
megCanicalKb authored Nov 20, 2017
2 parents 0386e50 + ea662c4 commit fbb0053
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions FBRetainCycleDetector/Detector/FBRetainCycleDetector.mm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ - (void)addCandidate:(id)candidate
[_candidates removeAllObjects];
[_objectSet removeAllObjects];

// Filter cycles that have been broken down since we found them.
// These are false-positive that were picked-up and are transient cycles.
NSMutableSet<NSArray<FBObjectiveCGraphElement *> *> *brokenCycles = [NSMutableSet set];
for (NSArray<FBObjectiveCGraphElement *> *itemCycle in allRetainCycles) {
for (FBObjectiveCGraphElement *element in itemCycle) {
if (element.object == nil) {
// At least one element of the cycle has been removed, thus breaking
// the cycle.
[brokenCycles addObject:itemCycle];
break;
}
}
}
[allRetainCycles minusSet:brokenCycles];

return allRetainCycles;
}

Expand Down
2 changes: 1 addition & 1 deletion FBRetainCycleDetector/Graph/FBObjectiveCBlock.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ - (NSString *)classNameOrNull
{
NSString *className = NSStringFromClass([self objectClass]);
if (!className) {
className = @"Null";
className = @"(null)";
}

if (!self.configuration.shouldIncludeBlockAddress) {
Expand Down
2 changes: 1 addition & 1 deletion FBRetainCycleDetector/Graph/FBObjectiveCGraphElement.mm
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ - (NSString *)classNameOrNull
{
NSString *className = NSStringFromClass([self objectClass]);
if (!className) {
className = @"Null";
className = @"(null)";
}

return className;
Expand Down

0 comments on commit fbb0053

Please sign in to comment.