Skip to content

Commit

Permalink
8284532: Memory leak in BitSet::BitMapFragmentTable in JFR leak profiler
Browse files Browse the repository at this point in the history
Backport-of: b55c32f5fe452e2b4e6f912a7d27f979e68ba67e
  • Loading branch information
zhengyu123 committed May 4, 2022
1 parent 70d3583 commit cf2b20f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/hotspot/share/jfr/leakprofiler/chains/bitset.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/jfr/leakprofiler/chains/bitset.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
};
Expand Down

1 comment on commit cf2b20f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.