RFR: 8267752: KVHashtable doesn't deallocate entries

Coleen Phillimore coleenp at openjdk.java.net
Wed Jun 16 12:36:36 UTC 2021


On Wed, 16 Jun 2021 05:58:05 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> Add a free_entry iteration to the destructor of ~KVHashtables.
>> Tested with tier1-3.
>
> src/hotspot/share/utilities/hashtable.hpp line 269:
> 
>> 267:         probe = *p;
>> 268:         *p = probe->next();
>> 269:         free_entry(probe);
> 
> I tried to understand `BasicHashTable::free_entry()` and `BasicHashTable::unlink_entry()`. I may be wrong, but the latter looks wrong. I expected some linked list splicing, but all it does is set the next ptr of the unlinked entry to NULL. So it would orphan follow up entries, and leave a dangling pointer to itself at its chain predecessor. I may be missing something here.
> 
> You code still seems to be correct since you manually walk the whole entry chain.

I hope unlink_entry isn't wrong because it's used for all the BasicHashtables.  It does orphan the further entries, but this entry has already been removed from the list. So setting the next isn't really necessary here, but decrementing the number of elements is for printing and logging.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4501


More information about the hotspot-dev mailing list