Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JNI memory leak  RSS feed

 
muthu muruges
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am accessing java from my 'c' code using JNI. My daemon is leaking memory in the JNI part. It looks like the GC is not running in the JVM. Please let me know how to fix that. I am using threads in 'c' code.

Thanks,
Muruges
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems rather unlikely that GC is not running at all. Various possibilities for memory leaks come to mind: -
  • You are using JNI functions to get things like the characters of a Java String or the elements of an array, but you are not always using the corresponding JNI function to release the associated memory, when you are finished with it.
  • You are using NewGlobalRef to get global references to Java objects, for use in your native code, but you are not deleting those global references when you are finished with them.
  • You have an ordinary, non JNI-related, memory leak in your native code.
  • You have an ordinary, non JNI-related leak in your Java code.

  •  
    muthu muruges
    Ranch Hand
    Posts: 70
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for the post. The leak is in my 'C' code only.

    Thanks again,
    Muruges
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!