Skip to content

Commit 9ccd7ba

Browse files
committed
Do not access JNI on Agent_OnLoad
1 parent 4ac0b99 commit 9ccd7ba

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

ddprof-lib/src/main/cpp/vmEntry.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,9 @@ void JNICALL VM::VMInit(jvmtiEnv* jvmti, JNIEnv* jni, jthread thread) {
535535
ready(jvmti, jni);
536536
loadAllMethodIDs(jvmti, jni);
537537

538+
// initialize the heap usage tracking only after the VM is ready
539+
ddprof::HeapUsage::initJMXUsage(VM::jni());
540+
538541
// Delayed start of profiler if agent has been loaded at VM bootstrap
539542
Error error = Profiler::instance()->run(_agent_args);
540543
if (error) {

ddprof-lib/src/main/cpp/vmStructs_dd.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ namespace ddprof {
4444
initOffsets();
4545
initJvmFunctions();
4646
initUnsafeFunctions();
47-
HeapUsage::initJMXUsage(VM::jni());
4847
}
4948

5049
void VMStructs_::initOffsets() {

0 commit comments

Comments
 (0)