diff --git a/test/hotspot/gtest/gtestMain.cpp b/test/hotspot/gtest/gtestMain.cpp index 51e6030d10e..f3d8bd60c98 100644 --- a/test/hotspot/gtest/gtestMain.cpp +++ b/test/hotspot/gtest/gtestMain.cpp @@ -92,6 +92,7 @@ static int init_jvm(int argc, char **argv, bool disable_error_handling, JavaVM** JNIEnv* env; int ret = JNI_CreateJavaVM(jvm_ptr, (void**)&env, &args); + delete[] options; if (ret == JNI_OK) { // CreateJavaVM leaves WXExec context, while gtests // calls internal functions assuming running in WXWwrite. diff --git a/test/hotspot/gtest/metaspace/metaspaceGtestSparseArray.hpp b/test/hotspot/gtest/metaspace/metaspaceGtestSparseArray.hpp index 91d3b841c00..4c8ad944d45 100644 --- a/test/hotspot/gtest/metaspace/metaspaceGtestSparseArray.hpp +++ b/test/hotspot/gtest/metaspace/metaspaceGtestSparseArray.hpp @@ -99,6 +99,10 @@ public: } } + ~SparseArray() { + FREE_C_HEAP_ARRAY(T, _slots); + } + T at(int i) { return _slots[i]; } const T at(int i) const { return _slots[i]; } void set_at(int i, T e) { _slots[i] = e; } diff --git a/test/hotspot/gtest/metaspace/test_freeblocks.cpp b/test/hotspot/gtest/metaspace/test_freeblocks.cpp index e51759dc1aa..1ad14d7fc22 100644 --- a/test/hotspot/gtest/metaspace/test_freeblocks.cpp +++ b/test/hotspot/gtest/metaspace/test_freeblocks.cpp @@ -79,7 +79,7 @@ class FreeBlocksTest { return false; } - void deallocate_top() { + bool deallocate_top() { allocation_t* a = _allocations; if (a != NULL) { @@ -88,7 +88,13 @@ class FreeBlocksTest { _freeblocks.add_block(a->p, a->word_size); delete a; DEBUG_ONLY(_freeblocks.verify();) + return true; } + return false; + } + + void deallocate_all() { + while (deallocate_top()); } bool allocate() { @@ -182,6 +188,10 @@ public: CHECK_CONTENT(_freeblocks, 1, 1024); } + ~FreeBlocksTest() { + deallocate_all(); + } + static void test_small_allocations() { FreeBlocksTest test(10); test.test_loop(); diff --git a/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp b/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp index 07c8b428998..daadee73331 100644 --- a/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp +++ b/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp @@ -538,6 +538,10 @@ TEST_VM(metaspace, virtual_space_node_test_basics) { ASSERT_EQ(node->committed_words(), (size_t)0); ASSERT_EQ(node->committed_words(), scomm.get()); DEBUG_ONLY(node->verify_locked();) + + delete node; + ASSERT_EQ(scomm.get(), (size_t)0); + ASSERT_EQ(sres.get(), (size_t)0); } // Note: we unfortunately need TEST_VM even though the system tested