Bug 135638 - HashTable based classes leak a lot
Summary: HashTable based classes leak a lot
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-05 20:38 PDT by Benjamin Poulain
Modified: 2014-08-10 01:45 PDT (History)
3 users (show)

See Also:


Attachments
Patch (2.20 KB, patch)
2014-08-05 20:43 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Poulain 2014-08-05 20:38:09 PDT
HashTable based classes leak a lot
Comment 1 Benjamin Poulain 2014-08-05 20:43:55 PDT
Created attachment 236078 [details]
Patch
Comment 2 Darin Adler 2014-08-05 20:48:07 PDT
Comment on attachment 236078 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=236078&action=review

Another fix would be to just add these two lines:

    if (m_table)
        deallocateTable(m_table, m_tableSize);

I suppose the swap idiom is more elegant, but it would be nice to double check that it’s just as efficient too.

> Source/WTF/wtf/HashTable.h:1236
> +        HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> temp = WTF::move(other);

You could write just HashTable here or just auto. No need for that long HashTable<xxxxxxxx> thing.
Comment 3 Benjamin Poulain 2014-08-05 22:15:09 PDT
(In reply to comment #2)
> (From update of attachment 236078 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=236078&action=review
> 
> Another fix would be to just add these two lines:
> 
>     if (m_table)
>         deallocateTable(m_table, m_tableSize);
> 
> I suppose the swap idiom is more elegant, but it would be nice to double check that it’s just as efficient too.

The previous version does not look like it was written to be efficient. It is zeroing the attributes that depends on the table being non null.

...but I'll check.
Comment 4 Benjamin Poulain 2014-08-06 13:08:17 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 236078 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=236078&action=review
> > 
> > Another fix would be to just add these two lines:
> > 
> >     if (m_table)
> >         deallocateTable(m_table, m_tableSize);
> > 
> > I suppose the swap idiom is more elegant, but it would be nice to double check that it’s just as efficient too.
> 
> The previous version does not look like it was written to be efficient. It is zeroing the attributes that depends on the table being non null.
> 
> ...but I'll check.

Ok, tried both on x86_64, the version with "if (m_table)" is significantly worse than the swap().
Comment 5 Benjamin Poulain 2014-08-06 13:12:34 PDT
Comment on attachment 236078 [details]
Patch

Clearing flags on attachment: 236078

Committed r172167: <http://trac.webkit.org/changeset/172167>
Comment 6 Benjamin Poulain 2014-08-06 13:12:37 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Darin Adler 2014-08-08 09:33:22 PDT
Comment on attachment 236078 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=236078&action=review

>> Source/WTF/wtf/HashTable.h:1236
>> +        HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> temp = WTF::move(other);
> 
> You could write just HashTable here or just auto. No need for that long HashTable<xxxxxxxx> thing.

Did you see this comment? I noticed you landed it with the long thing.
Comment 8 Benjamin Poulain 2014-08-08 14:57:03 PDT
(In reply to comment #7)
> (From update of attachment 236078 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=236078&action=review
> 
> >> Source/WTF/wtf/HashTable.h:1236
> >> +        HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> temp = WTF::move(other);
> > 
> > You could write just HashTable here or just auto. No need for that long HashTable<xxxxxxxx> thing.
> 
> Did you see this comment? I noticed you landed it with the long thing.

I am one of the dinosaurs who find code a lot harder to read with "auto" :)

If you feel strongly about it, I'll update to auto.
Comment 9 Darin Adler 2014-08-08 17:44:31 PDT
Comment on attachment 236078 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=236078&action=review

>>>> Source/WTF/wtf/HashTable.h:1236
>>>> +        HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> temp = WTF::move(other);
>>> 
>>> You could write just HashTable here or just auto. No need for that long HashTable<xxxxxxxx> thing.
>> 
>> Did you see this comment? I noticed you landed it with the long thing.
> 
> I am one of the dinosaurs who find code a lot harder to read with "auto" :)
> 
> If you feel strongly about it, I'll update to auto.

Since you don’t like auto, you can do this:

    HashTable temp = WTF::move(other);

To me it reads even better with auto, but I understand that you don’t like it. That’s why I said “just HashTable” *or* “just auto”.
Comment 10 Benjamin Poulain 2014-08-08 18:00:09 PDT
(In reply to comment #9)
> (From update of attachment 236078 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=236078&action=review
> 
> >>>> Source/WTF/wtf/HashTable.h:1236
> >>>> +        HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits> temp = WTF::move(other);
> >>> 
> >>> You could write just HashTable here or just auto. No need for that long HashTable<xxxxxxxx> thing.
> >> 
> >> Did you see this comment? I noticed you landed it with the long thing.
> > 
> > I am one of the dinosaurs who find code a lot harder to read with "auto" :)
> > 
> > If you feel strongly about it, I'll update to auto.
> 
> Since you don’t like auto, you can do this:
> 
>     HashTable temp = WTF::move(other);
> 
> To me it reads even better with auto, but I understand that you don’t like it. That’s why I said “just HashTable” *or* “just auto”.

Oh, I misunderstood the part about HashTable. I agree HashTable is better, I will update.
Comment 11 Benjamin Poulain 2014-08-10 01:45:46 PDT
Fixed the type in r172378: <http://trac.webkit.org/changeset/172378>