Skip to content

Commit 1aff44b

Browse files
committed
8279949: JavaThread::_free_handle_block leaks native memory
Reviewed-by: dholmes, coleenp
1 parent 394ce5f commit 1aff44b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/hotspot/share/runtime/jniHandles.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -384,10 +384,15 @@ void JNIHandleBlock::release_block(JNIHandleBlock* block, JavaThread* thread) {
384384
block->_next = freelist;
385385
}
386386
block = NULL;
387-
}
388-
if (block != NULL) {
389-
Atomic::dec(&_blocks_allocated);
390-
delete block;
387+
} else {
388+
DEBUG_ONLY(block->set_pop_frame_link(NULL));
389+
while (block != NULL) {
390+
JNIHandleBlock* next = block->_next;
391+
Atomic::dec(&_blocks_allocated);
392+
assert(block->pop_frame_link() == NULL, "pop_frame_link should be NULL");
393+
delete block;
394+
block = next;
395+
}
391396
}
392397
if (pop_frame_link != NULL) {
393398
// As a sanity check we release blocks pointed to by the pop_frame_link.

0 commit comments

Comments
 (0)