8297911: Memory leak in JfrUpcalls::on_retransform
Reviewed-by: mgronlun
This commit is contained in:
parent
5c0ff26f32
commit
1376f33011
@ -1524,22 +1524,19 @@ static ClassFileStream* retransform_bytes(const Klass* existing_klass, const Cla
|
|||||||
DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));
|
DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));
|
||||||
jint size_of_new_bytes = 0;
|
jint size_of_new_bytes = 0;
|
||||||
unsigned char* new_bytes = NULL;
|
unsigned char* new_bytes = NULL;
|
||||||
{
|
const ClassFileStream* const stream = parser.clone_stream();
|
||||||
ResourceMark rm(THREAD);
|
assert(stream != NULL, "invariant");
|
||||||
const ClassFileStream* const stream = parser.clone_stream();
|
const jclass clazz = static_cast<jclass>(JfrJavaSupport::local_jni_handle(existing_klass->java_mirror(), THREAD));
|
||||||
assert(stream != NULL, "invariant");
|
JfrUpcalls::on_retransform(JfrTraceId::load_raw(existing_klass),
|
||||||
const jclass clazz = static_cast<jclass>(JfrJavaSupport::local_jni_handle(existing_klass->java_mirror(), THREAD));
|
clazz,
|
||||||
JfrUpcalls::on_retransform(JfrTraceId::load_raw(existing_klass),
|
stream->length(),
|
||||||
clazz,
|
stream->buffer(),
|
||||||
stream->length(),
|
&size_of_new_bytes,
|
||||||
stream->buffer(),
|
&new_bytes,
|
||||||
&size_of_new_bytes,
|
THREAD);
|
||||||
&new_bytes,
|
JfrJavaSupport::destroy_local_jni_handle(clazz);
|
||||||
THREAD);
|
if (has_pending_exception(THREAD)) {
|
||||||
JfrJavaSupport::destroy_local_jni_handle(clazz);
|
return NULL;
|
||||||
if (has_pending_exception(THREAD)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
assert(new_bytes != NULL, "invariant");
|
assert(new_bytes != NULL, "invariant");
|
||||||
assert(size_of_new_bytes > 0, "invariant");
|
assert(size_of_new_bytes > 0, "invariant");
|
||||||
|
@ -141,9 +141,7 @@ void JfrUpcalls::on_retransform(jlong trace_id,
|
|||||||
CHECK);
|
CHECK);
|
||||||
assert(new_byte_array != NULL, "invariant");
|
assert(new_byte_array != NULL, "invariant");
|
||||||
assert(new_bytes_length > 0, "invariant");
|
assert(new_bytes_length > 0, "invariant");
|
||||||
// memory space must be malloced as mtInternal
|
unsigned char* const new_bytes = NEW_RESOURCE_ARRAY_IN_THREAD_RETURN_NULL(THREAD, unsigned char, new_bytes_length);
|
||||||
// as it will be deallocated by JVMTI routines
|
|
||||||
unsigned char* const new_bytes = (unsigned char* const)os::malloc(new_bytes_length, mtInternal);
|
|
||||||
if (new_bytes == NULL) {
|
if (new_bytes == NULL) {
|
||||||
log_error_and_throw_oom(new_bytes_length, THREAD); // unwinds
|
log_error_and_throw_oom(new_bytes_length, THREAD); // unwinds
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user