8303605: Memory leaks in Metaspace gtests
Reviewed-by: stuefe, dholmes
This commit is contained in:
parent
56512cfe1f
commit
ddcb369cea
@ -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.
|
||||
|
@ -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; }
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user