Bug 21924 - HashTable internal index is not always deleted
Summary: HashTable internal index is not always deleted
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-28 08:48 PDT by Frederic Marmond
Modified: 2008-10-29 03:35 PDT (History)
3 users (show)

See Also:


Attachments
fix a memory leak on HashTable (1.13 KB, patch)
2008-10-28 08:49 PDT, Frederic Marmond
ap: review-
Details | Formatted Diff | Diff
proposed fix (1.46 KB, patch)
2008-10-28 09:49 PDT, Alexey Proskuryakov
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Marmond 2008-10-28 08:48:01 PDT
HashTable::createTable() allocates new HashEntry array, but HashTable::deleteTable() is not always called, so this array may not be deleted.

It can then introduce memory leaks, valgrind gives one of around 800ko on a single gmail visit.

My fix is to call the deleteTable() in the HashTable destructor.
It is secured and fixes the memory leak.
Comment 1 Frederic Marmond 2008-10-28 08:49:04 PDT
Created attachment 24714 [details]
fix a memory leak on HashTable
Comment 2 Alexey Proskuryakov 2008-10-28 09:15:59 PDT
Comment on attachment 24714 [details]
fix a memory leak on HashTable

HashTable::deleteTable is called from JSGlobalData destructor to avoid having destructors for static objects, which this patch would introduce.

However, the problem is real - in WebCore/bindings/js/JSDOMBinding.cpp, DOMObjectHashTableMap isn't properly cleaned up! This only affects worker threads though.
Comment 3 Alexey Proskuryakov 2008-10-28 09:49:41 PDT
Created attachment 24719 [details]
proposed fix

Fix the problem in WebCore.
Comment 4 Darin Adler 2008-10-28 09:51:46 PDT
Comment on attachment 24719 [details]
proposed fix

r=me
Comment 5 Alexey Proskuryakov 2008-10-29 03:35:44 PDT
Committed revision 37968.