Bug 144721

Summary: Worker threads leak WeakBlocks (as seen on leaks bot)
Product: WebKit Reporter: Andreas Kling <kling>
Component: JavaScriptCoreAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ggaren
Priority: P2 Keywords: Performance
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Andreas Kling 2015-05-06 18:06:35 PDT
<rdar://problem/20848288>

We've got about 750 KB worth of WeakBlocks leaked on the leaks bot right now. Boo.
Comment 1 Andreas Kling 2015-05-06 18:10:58 PDT
Created attachment 252547 [details]
Patch
Comment 2 Darin Adler 2015-05-07 09:25:11 PDT
Comment on attachment 252547 [details]
Patch

I think we return here and use std::unique_ptr for this. It would remove the need to explicitly call WeakBlock::destroy in Heap::sweepNextLogicallyEmptyWeakBlock. I know this is low-level code and std::unique_ptr might seem out of place, but I think it would cleanly prevent a mistake like this one!
Comment 3 Andreas Kling 2015-05-07 10:42:41 PDT
(In reply to comment #2)
> Comment on attachment 252547 [details]
> Patch
> 
> I think we return here and use std::unique_ptr for this. It would remove the
> need to explicitly call WeakBlock::destroy in
> Heap::sweepNextLogicallyEmptyWeakBlock. I know this is low-level code and
> std::unique_ptr might seem out of place, but I think it would cleanly
> prevent a mistake like this one!

That's not a bad idea. I glossed over it because I assumed WeakBlocks were aligned to their block size, but it turns out that they're just plain fastMalloc()'ed objects.

With a little care, we can fix these up to live in unique_ptr. Landing this right away to unscrew leaks bot though.
Comment 4 Geoffrey Garen 2015-05-07 11:02:58 PDT
> I think we return here and use std::unique_ptr for this. It would remove the
> need to explicitly call WeakBlock::destroy in
> Heap::sweepNextLogicallyEmptyWeakBlock. I know this is low-level code and
> std::unique_ptr might seem out of place, but I think it would cleanly
> prevent a mistake like this one!

I agree. Once upon a time it was not practical to unique_ptr these objects, but now it should be pretty trivial.
Comment 5 WebKit Commit Bot 2015-05-07 11:33:51 PDT
Comment on attachment 252547 [details]
Patch

Clearing flags on attachment: 252547

Committed r183938: <http://trac.webkit.org/changeset/183938>
Comment 6 WebKit Commit Bot 2015-05-07 11:33:55 PDT
All reviewed patches have been landed.  Closing bug.