Skip to content

Commit

Permalink
8279949: JavaThread::_free_handle_block leaks native memory
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, coleenp
  • Loading branch information
lmesnik committed Feb 15, 2022
1 parent 394ce5f commit 1aff44b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/hotspot/share/runtime/jniHandles.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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 @@ -384,10 +384,15 @@ void JNIHandleBlock::release_block(JNIHandleBlock* block, JavaThread* thread) {
block->_next = freelist;
}
block = NULL;
}
if (block != NULL) {
Atomic::dec(&_blocks_allocated);
delete block;
} else {
DEBUG_ONLY(block->set_pop_frame_link(NULL));
while (block != NULL) {
JNIHandleBlock* next = block->_next;
Atomic::dec(&_blocks_allocated);
assert(block->pop_frame_link() == NULL, "pop_frame_link should be NULL");
delete block;
block = next;
}
}
if (pop_frame_link != NULL) {
// As a sanity check we release blocks pointed to by the pop_frame_link.
Expand Down

1 comment on commit 1aff44b

@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.