8284532: Memory leak in BitSet::BitMapFragmentTable in JFR leak profiler

Reviewed-by: stuefe, mgronlun, shade
This commit is contained in:
Zhengyu Gu 2022-04-08 14:58:05 +00:00
parent 8eac3427b1
commit b55c32f5fe
2 changed files with 14 additions and 2 deletions
src/hotspot/share/jfr/leakprofiler/chains

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,17 @@ BitSet::BitMapFragment::BitMapFragment(uintptr_t granule, BitMapFragment* next)
_next(next) {
}
BitSet::BitMapFragmentTable::~BitMapFragmentTable() {
for (int index = 0; index < table_size(); index ++) {
Entry* e = bucket(index);
while (e != nullptr) {
Entry* tmp = e;
e = e->next();
free_entry(tmp);
}
}
}
BitSet::BitSet() :
_bitmap_fragments(32),
_fragment_list(NULL),

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -68,6 +68,7 @@ class BitSet : public CHeapObj<mtTracing> {
public:
BitMapFragmentTable(int table_size) : BasicHashtable<mtTracing>(table_size, sizeof(Entry)) {}
~BitMapFragmentTable();
void add(uintptr_t key, CHeapBitMap* value);
CHeapBitMap** lookup(uintptr_t key);
};