New issue
Advanced search Search tips

Issue 733017 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner:
Closed: Sep 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

Potential memory leak in -[HandoffManager updateUserActivity].

Project Member Reported by erikc...@chromium.org, Jun 13 2017

Issue description

I've been looking at sources of browser memory bloat by using native heap profiling on my own browser. Full details:
https://docs.google.com/document/d/1fN5balfyrd7sRpd6DRaUI1TwoOwYjLyRSd7mwZT5US8/edit#

Over the course of 1 week, the browser process created ~1k NSUserActivity objects that it did not destroy. 

This is suggestive of a large leak. 

Each screenshot shows:
  1) # of objects created [that have not been destroyed]
  2) The stack trace of the code that created the object.
 
Screen Shot 2017-06-13 at 4.23.30 PM.png
338 KB View Download
Hm. At first I thought this might be related to RVO, sine the following lines look really suspicious:

"""
  NSUserActivity* userActivity = [[aClass performSelector:@selector(alloc)]
      performSelector:@selector(initWithActivityType:)
           withObject:handoff::kChromeHandoffActivityType];
  self.userActivity = base::scoped_nsobject<NSUserActivity>(userActivity);
"""

But I'm pretty sure that works as intended. So the only thing I can think of is that maybe we're misusing Handoff objects, or else the library is over-retaining.
Project Member

Comment 2 by bugdroid1@chromium.org, Jun 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/270e22d3713afcb3fec87282e71ec00e394a2e97

commit 270e22d3713afcb3fec87282e71ec00e394a2e97
Author: erikchen <erikchen@chromium.org>
Date: Fri Jun 16 22:06:04 2017

Minor refactor to HandoffManager.

NSUserActivity were being created, and then wrapped in a temporary
base::scoped_nsobject. Instead, immediately wrap in a base::scoped_nsobject on
creation.

BUG= 733017 

Review-Url: https://codereview.chromium.org/2940193002
Cr-Commit-Position: refs/heads/master@{#480190}

[modify] https://crrev.com/270e22d3713afcb3fec87282e71ec00e394a2e97/components/handoff/handoff_manager.mm

Comment 3 by lgrey@chromium.org, Jun 19 2017

This is probably unrelated, due to the stack trace, but if you're in the AppNap experiment, there's a new NSUserActivity for each renderer: https://cs.chromium.org/chromium/src/content/child/child_thread_impl.h?sq=package:chromium&type=cs&l=289
https://cs.chromium.org/chromium/src/content/common/mac/app_nap_activity.h?sq=package:chromium&dr
Status: WontFix (was: Assigned)
I'm no longer seeing this issue, and the AppNap code is no longer there? Coincidence? Maybe we'll never know.

Sign in to add a comment