Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider warning about longish JNI critical section for the byte[]-based API #346

Open
bbrehm opened this issue Jan 24, 2025 · 0 comments
Open

Comments

@bbrehm
Copy link

bbrehm commented Jan 24, 2025

The byte array based API does all the work in JNI critical sections (e.g.

void *dst_buff = (*env)->GetPrimitiveArrayCritical(env, dst, NULL);
).

This is liable to cause OOM crashes when using that with G1 GC without region pinning https://openjdk.org/jeps/423, i.e. in a runtime before java 22.

I think a warning in the docs would be appropriate.

Or one could allocate a temp buffer in the C world, and only hold the critical section for the time of a memcpy.

PS. some other background: https://shipilev.net/jvm/anatomy-quarks/9-jni-critical-gclocker/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant