Potential memory leak in -[HandoffManager updateUserActivity]. |
||
Issue descriptionI'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.
,
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
,
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
,
Sep 28 2017
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 |
||
Comment 1 by erikc...@chromium.org
, Jun 15 2017Hm. 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.