Skip to content

Do native functions returning string (char*) leak memory? #216

@setzer22

Description

@setzer22

Sorry if this is sounds more like a question than an actual issue. I found no better place to ask this (if there's such a place, please let me know!)

I have a native function that allocates a string to the heap and returns a pointer to it. When I call this function using jnr-ffi, everything works as expected and I get a java string at the other side. However, I'm unsure whether I'm leaking memory by doing this. I'm assuming jnr-ffi is copying the string memory at some point, but is it free-ing the memory that was allocated by the native code?

If not, is there a way I can have my native library safely return a string without leaking memory?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions