Forum Stats

  • 3,750,523 Users
  • 2,250,188 Discussions
  • 7,866,998 Comments

Discussions

question about the return pointer of GetCharArrayElements

user3456293
user3456293 Member Posts: 1
edited Jun 18, 2015 4:29PM in Generics

I am using Java Native Interfaces(JNI). I need to read the content of a char array, so I am going to use GetCharArrayElements. It returns a pointer to a array of native char. Shall I need to release the memory pointed by the pointer at last? To avoid memory leaks, I am asking this question here. Thanks for any hints in advance.

Answers

  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877
    edited Jun 18, 2015 4:29PM

    There is a JNI forum and "Generics" is something completely different.

    Myself I like to release it because it gives me a warm and fuzzy feeling but as I recall JNI for some time has required the context to release itself after the call returns to java.  That said if you were doing a lot of processing I suspect it would still be a good idea to explicitly release it.

This discussion has been closed.