Skip to content

Simplify Java/JNI local objects life cycle #3398

Description

@Meakk

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: #3333

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status
    Discuss

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions