changeset 57298:f55c453cef06

8235346: [Redo] 8235247: WorkerDataArray leaks C heap memory for associated work items Summary: Fix gtest after last iteration to acknowledge correct ownership of sub-WorkerDataArrays. Reviewed-by: lkorinth, sjohanss
author tschatzl
date Fri, 06 Dec 2019 09:49:57 +0100
parents d6fe7d58d994
children ada146daf105
files src/hotspot/share/gc/shared/workerDataArray.inline.hpp test/hotspot/gtest/gc/shared/test_workerDataArray.cpp
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shared/workerDataArray.inline.hpp	Fri Dec 06 13:42:57 2019 +0530
+++ b/src/hotspot/share/gc/shared/workerDataArray.inline.hpp	Fri Dec 06 09:49:57 2019 +0100
@@ -59,6 +59,9 @@
 
 template <typename T>
 WorkerDataArray<T>::~WorkerDataArray() {
+  for (uint i = 0; i < MaxThreadWorkItems; i++) {
+    delete _thread_work_items[i];
+  }
   FREE_C_HEAP_ARRAY(T, _data);
 }
 
--- a/test/hotspot/gtest/gc/shared/test_workerDataArray.cpp	Fri Dec 06 13:42:57 2019 +0530
+++ b/test/hotspot/gtest/gc/shared/test_workerDataArray.cpp	Fri Dec 06 09:49:57 2019 +0100
@@ -35,10 +35,9 @@
   WorkerDataArrayTest() :
     title("Test array"),
     array(3, title),
-    sub_item_title("Sub item array"),
-    sub_item(3, sub_item_title) {
+    sub_item_title("Sub item array") {
 
-    array.link_thread_work_items(&sub_item);
+    array.link_thread_work_items(new WorkerDataArray<size_t>(3, sub_item_title));
   }
 
   const char* print_summary() {
@@ -70,7 +69,6 @@
   WorkerDataArray<T> array;
 
   const char* sub_item_title;
-  WorkerDataArray<size_t> sub_item;
 
  private:
   virtual const char* expected_summary() = 0;