0

I've been taking heapshots of a certain process. All the leaked objects in all the shots originate in this method:

- (void)setArticle:(Article *)article
{
    if (_article != article)
    {
        [self.navigationController popToViewController:self animated:YES];

        [_article removeObserver:self forKeyPath:kArticleObservationKey];
        [_article release];
        _article = [article retain];

        [_article addObserver:self forKeyPath:kArticleObservationKey options:NSKeyValueObservingOptionNew context:&__ArticleObservingContext];

        [_article loadIfNeededWithPriority:OGRequestPriorityHigh downloadAllImage:NO];
        [_article fetchRelatedStories];
    }

    [self resetArticleView]; // 65% of heapshot allocations

    if ([_article.isStub boolValue])
    {
        [self.view showSpinner];
    }

    if (_article)
    {
        [Analytics articleReadWithParmeters:[NSDictionary dictionaryWithObject:_article.idOnServer forKey:AnalyticsKeyArticleId]]; // 32% of heapshot allocations
    }
}

Here is the actual heapshot, they all look identical to this:

Heapshot

I've got few questions:

  1. What are my next steps? I don't see any leaks in this method, why is it featured so prominently in the heapshots?
  2. The [self resetArticleView] has a little 65% next to it, but that particular method shows up in none of the stack traces for my leaked objects. Am I misunderstanding what that particular 65% designation means? If it does mean that it contains 65% of the leaked allocations, why is that method not in any stack traces?
kubi
  • 48,104
  • 19
  • 94
  • 118

1 Answers1

3

Turn on retain event tracking in the allocations instrument and see what is retaining the objects...

You'll likely find this interesting, too. When is a Leak not a leak? Heapshot Analysis

Note that the point of leak and the point of allocation may not be the same, which is why you'll see methods showing up that don't show up in any current backtrace; the method may be the source of the allocation, but the leak itself is due to an over-retain elsewhere.

(I'm not sure what % you are referring to -- got a screenshot of that?)

bbum
  • 162,346
  • 23
  • 271
  • 359
  • That's what I needed. All the objects are being leaked inside our analytics framework, so they're effectively out of reach. – kubi Jul 26 '11 at 16:02
  • While you're here, can you tell my what the "65%" next to the `[self resetArticleView]` means? None of the objects found in the heapshot come from that method. What does that number signify? – kubi Jul 26 '11 at 16:03
  • Where do I turn on "Retain event tracking"? I can't seem to find this option in the allocations instrument. Everytime I try to see an object's retain history I can't seem to find anything. – futureelite7 Jul 29 '11 at 08:16