这个Heapshot是什么意思?

发布于 2024-11-26 12:22:46 字数 1291 浏览 1 评论 0原文

我一直在拍摄某个过程的快照。所有镜头中所有泄漏的对象都源于此方法:

- (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
    }
}

这是实际的堆镜头,它们看起来都与此相同:

Heapshot

我有几个问题:

  1. 我的下一步是什么?我没有看到这个方法有任何漏洞,为什么它在堆图中如此突出?
  2. [self resetArticleView] 旁边有一点 65%,但该特定方法没有出现在我泄漏的对象的堆栈跟踪中。我是否误解了那个特定的 65% 指定的含义?如果这确实意味着它包含 65% 的泄漏分配,为什么该方法不在任何堆栈跟踪中?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花细雨 2024-12-03 12:22:46

在分配工具中打开保留事件跟踪,看看是什么保留了对象......

您可能也会发现这很有趣。 什么时候泄漏不是泄漏?堆快照分析

请注意,泄漏点和分配点可能不同,这就是为什么您会看到出现在任何当前回溯中都没有出现的方法;该方法可能是分配的来源,但泄漏本身是由于其他地方的过度保留造成的。

(我不确定你指的是多少%——有截图吗?)

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?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文