Skip to content

Commit d777717

Browse files
fix leak in Java event TLBs
1 parent 9a2d042 commit d777717

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrThreadLocal.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ public UnsignedWord getThreadLocalBufferSize() {
123123
}
124124

125125
public void teardown() {
126+
// At this point all native buffers should be freed already.
126127
getNativeBufferList().teardown();
128+
// At this point Java buffers will be retired or freed.
127129
getJavaBufferList().teardown();
128130
}
129131

@@ -161,10 +163,11 @@ public static void stopRecording(IsolateThread isolateThread, boolean freeJavaBu
161163
flushToGlobalMemoryAndFreeBuffer(nb);
162164

163165
JfrBuffer jb = javaBuffer.get(isolateThread);
164-
javaBuffer.set(isolateThread, Word.nullPointer());
165166
if (freeJavaBuffer) {
167+
javaBuffer.set(isolateThread, Word.nullPointer());
166168
flushToGlobalMemoryAndFreeBuffer(jb);
167169
} else {
170+
// Do not reset the thread local since we may need it to reinstate the buffer in the next recording.
168171
flushToGlobalMemoryAndRetireBuffer(jb);
169172
}
170173

0 commit comments

Comments
 (0)