Skip to content
Permalink
Browse files
8267752: KVHashtable doesn't deallocate entries
Reviewed-by: iklam, stuefe
  • Loading branch information
coleenp committed Jun 16, 2021
1 parent af13fe1 commit 72b3b0af08136342e54e1cdea0c48d64172e8870
Showing with 20 additions and 0 deletions.
  1. +20 −0 src/hotspot/share/utilities/hashtable.hpp
@@ -242,15 +242,35 @@ class KVHashtable : public BasicHashtable<F> {
return (KVHashtableEntry*)BasicHashtable<F>::bucket(i);
}

// The following method is not MT-safe and must be done under lock.
KVHashtableEntry** bucket_addr(int i) {
return (KVHashtableEntry**)BasicHashtable<F>::bucket_addr(i);
}

KVHashtableEntry* new_entry(unsigned int hashValue, K key, V value) {
KVHashtableEntry* entry = (KVHashtableEntry*)BasicHashtable<F>::new_entry(hashValue);
entry->_key = key;
entry->_value = value;
return entry;
}

void free_entry(KVHashtableEntry* entry) {
BasicHashtable<F>::free_entry(entry);
}

public:
KVHashtable(int table_size) : BasicHashtable<F>(table_size, sizeof(KVHashtableEntry)) {}
~KVHashtable() {
KVHashtableEntry* probe = NULL;
for (int index = 0; index < table_size(); index++) {
for (KVHashtableEntry** p = bucket_addr(index); *p != NULL; ) {
probe = *p;
*p = probe->next();
free_entry(probe);
}
}
assert(BasicHashtable<F>::number_of_entries() == 0, "should have removed all entries");
}

V* add(K key, V value) {
unsigned int hash = HASH(key);

1 comment on commit 72b3b0a

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 72b3b0a Jun 16, 2021

Please sign in to comment.