RESOLVED FIXED84307
[WK2] AlternativeTextClient leaks when the page is destroyed
https://bugs.webkit.org/show_bug.cgi?id=84307
Summary [WK2] AlternativeTextClient leaks when the page is destroyed
Andreas Kling
Reported 2012-04-18 17:55:03 PDT
There is nobody deleting the WebKit::WebAlternativeTextClient AFAICT. Opening and closing a couple of pages, and then running "leaks" will show you that a bunch of WebAlternativeTextClient objects have leaked.
Attachments
Fix memory leak. (7.54 KB, patch)
2012-04-19 12:02 PDT, Jia Pu
no flags
Use OwnPtr. (2.43 KB, patch)
2012-04-23 14:02 PDT, Jia Pu
no flags
Patch (8.14 KB, patch)
2012-04-26 14:29 PDT, Jon Lee
enrica: review+
Jia Pu
Comment 1 2012-04-18 18:19:09 PDT
Will take a look.
Jia Pu
Comment 2 2012-04-19 12:02:21 PDT
Created attachment 137942 [details] Fix memory leak.
Eric Seidel (no email)
Comment 3 2012-04-19 14:31:54 PDT
I thought we had a PageObserver pattern these days?
Eric Seidel (no email)
Comment 4 2012-04-19 14:32:14 PDT
I guess only FrameDestructionObserver.
Ryosuke Niwa
Comment 5 2012-04-21 18:46:35 PDT
Comment on attachment 137942 [details] Fix memory leak. View in context: https://bugs.webkit.org/attachment.cgi?id=137942&action=review > Source/WebKit/mac/WebCoreSupport/WebAlternativeTextClient.mm:45 > +void WebAlternativeTextClient::pageDestroyed() > +{ > + delete this; > +} Really? We need to manually call delete on this? Can't we use OwnPtr instead?
Jia Pu
Comment 6 2012-04-21 19:05:16 PDT
(In reply to comment #5) > (From update of attachment 137942 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=137942&action=review > > > Source/WebKit/mac/WebCoreSupport/WebAlternativeTextClient.mm:45 > > +void WebAlternativeTextClient::pageDestroyed() > > +{ > > + delete this; > > +} > > Really? We need to manually call delete on this? Can't we use OwnPtr instead? I am just following this pattern in various other clients. I can certainly just release it on WebCore side.
Tim Horton
Comment 7 2012-04-22 19:36:49 PDT
Comment on attachment 137942 [details] Fix memory leak. View in context: https://bugs.webkit.org/attachment.cgi?id=137942&action=review > Source/WebKit2/ChangeLog:8 > + Fixing memory leak. The changelog entry could definitely be slightly more informative re: what situation we were leaking in and how it's fixed; as it stands, it's impossible to know much about what's going on without looking at the change itself.
Jia Pu
Comment 8 2012-04-23 14:02:03 PDT
Created attachment 138421 [details] Use OwnPtr.
Darin Adler
Comment 9 2012-04-23 15:19:06 PDT
The other clients aren’t owned like this. Why is the pattern different for this one?
Darin Adler
Comment 10 2012-04-23 15:20:15 PDT
(In reply to comment #5) > We need to manually call delete on this? Can't we use OwnPtr instead? We shouldn’t because the ownership is not something Page enforces. It’s something that can vary per-port. If we were going to use OwnPtr we’d want to use it in the clients structure itself and remove the flexibility of having the clients not all be separate objects, flexibility we have today.
Darin Adler
Comment 11 2012-04-23 15:21:01 PDT
Another way to put it is that if we are going to use OwnPtr, then the adoptPtr needs to be right next to the new, not inside the Page constructor’s implementation.
Jia Pu
Comment 12 2012-04-23 15:24:03 PDT
Would the first patch look OK then?
Jon Lee
Comment 13 2012-04-26 12:57:22 PDT
*** Bug 84984 has been marked as a duplicate of this bug. ***
Jon Lee
Comment 14 2012-04-26 12:59:06 PDT
Jon Lee
Comment 15 2012-04-26 13:01:43 PDT
I had filed a similar bug and posted a patch exactly like the _first_ one that Jia had posted. The pattern, while not ideal, is established in other clients. So given that my patch is exactly what Jia did, I would unofficially r+ the first patch.
Jon Lee
Comment 16 2012-04-26 14:28:28 PDT
Talked to Jia offline, reassigning to me.
Jon Lee
Comment 17 2012-04-26 14:29:09 PDT
Enrica Casucci
Comment 18 2012-04-26 14:31:49 PDT
Comment on attachment 139071 [details] Patch Looks good.
Jon Lee
Comment 19 2012-04-26 14:34:44 PDT
Note You need to log in before you can comment on or make changes to this bug.