这个Heapshot是什么意思?
我一直在拍摄某个过程的快照。所有镜头中所有泄漏的对象都源于此方法:
- (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
}
}
这是实际的堆镜头,它们看起来都与此相同:
我有几个问题:
- 我的下一步是什么?我没有看到这个方法有任何漏洞,为什么它在堆图中如此突出?
[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:
I've got few questions:
- What are my next steps? I don't see any leaks in this method, why is it featured so prominently in the heapshots?
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在分配工具中打开保留事件跟踪,看看是什么保留了对象......
您可能也会发现这很有趣。 什么时候泄漏不是泄漏?堆快照分析
请注意,泄漏点和分配点可能不同,这就是为什么您会看到出现在任何当前回溯中都没有出现的方法;该方法可能是分配的来源,但泄漏本身是由于其他地方的过度保留造成的。
(我不确定你指的是多少%——有截图吗?)
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?)