f3d icon indicating copy to clipboard operation
f3d copied to clipboard

Simplify Java/JNI local objects life cycle

Open Meakk opened this issue 4 months ago • 4 comments

Describe the bug In the Java bindings, many local objects are allocated and released manually, introducing potential memory leaks if not careful.

It's especially true for strings where we write things like this in different places:

const char* rawStr = env->GetStringUTFChars(str, nullptr);

// do something

env->ReleaseStringUTFChars(str, rawStr);

We should rely on RAII helpers instead.

Expected behavior We should never allocate/release outside of the RAII helpers. Related files in java directory.

Additional context This needs to be merged first: https://github.com/f3d-app/f3d/pull/3333

Meakk avatar Jul 20 '26 07:07 Meakk

I'd like to take this after #3333 is merged.

kaili-yang avatar Jul 20 '26 21:07 kaili-yang

Unassinged as discussed.

mwestphal avatar Jul 23 '26 20:07 mwestphal

Hey @mwestphal is someone working on this? if not can you assign me this?

midaksh avatar Aug 04 '26 19:08 midaksh

Assigned!

mwestphal avatar Aug 05 '26 08:08 mwestphal