RESOLVED FIXED 135638
HashTable based classes leak a lot
https://bugs.webkit.org/show_bug.cgi?id=135638
Summary HashTable based classes leak a lot
Benjamin Poulain
Reported 2014-08-05 20:38:09 PDT
HashTable based classes leak a lot
Attachments
Patch (2.20 KB, patch)
2014-08-05 20:43 PDT, Benjamin Poulain
no flags
Benjamin Poulain
Comment 1 2014-08-05 20:43:55 PDT
Darin Adler
Comment 2 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.
Benjamin Poulain
Comment 3 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.
Benjamin Poulain
Comment 4 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().
Benjamin Poulain
Comment 5 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>
Benjamin Poulain
Comment 6 2014-08-06 13:12:37 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 7 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.
Benjamin Poulain
Comment 8 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.
Darin Adler
Comment 9 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”.
Benjamin Poulain
Comment 10 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.
Benjamin Poulain
Comment 11 2014-08-10 01:45:46 PDT
Note You need to log in before you can comment on or make changes to this bug.