Resource leak in Java bindings
|
20-06-2013, 10:10 PM
(This post was last modified: 20-06-2013 10:11 PM by simoncn.)
Post: #1
|
|||
|
|||
Resource leak in Java bindings
I've discovered a resource leak in the Java bindings. The callback references created by InitParams.setLogOutput() and InitParams.setFatalErrorHandler() aren't being freed when the ohNet library is closed.
At first sight, this might not seem like a big problem, but it has some very unfortunate side-effects. These unfreed references prevent the classloader from being garbage collected, which in turn prevents the ohNet native libraries from being unloaded, which means the Java application can't re-initialize ohNet from a new classloader. I've created a patch to fix this. It requires changes to the following files: InitParams.c InitParams.h InitParams.java Library.java I'm attaching a zip file containing the full updated versions of all these files and diffs for the changes. I've tested the changes on Windows and Linux and I've confirmed that this resolves the classloader issues. While doing this, I noticed some CR/LF line ending problems in InitParams.java and Library.java, and I've included changes to convert these CR/LF endings into LF endings. |
|||
25-06-2013, 08:01 AM
Post: #2
|
|||
|
|||
RE: Resource leak in Java bindings
(20-06-2013 10:10 PM)simoncn Wrote: I've discovered a resource leak in the Java bindings. The callback references created by InitParams.setLogOutput() and InitParams.setFatalErrorHandler() aren't being freed when the ohNet library is closed. Thanks for tracking this down! I've applied the changes now so they should be on github this evening. |
|||
26-06-2013, 08:53 PM
Post: #3
|
|||
|
|||
RE: Resource leak in Java bindings | |||
10-07-2013, 08:21 PM
Post: #4
|
|||
|
|||
RE: Resource leak in Java bindings
(26-06-2013 08:53 PM)simoncn Wrote: Thanks very much! I've downloaded and tested the latest tag from github and it is working fine so far. I've found a similar problem in the control point stack (related to property callbacks). A patch is attached. Please let me know if you have any questions about the changes. |
|||
11-07-2013, 01:53 PM
Post: #5
|
|||
|
|||
RE: Resource leak in Java bindings | |||
12-07-2013, 03:18 PM
Post: #6
|
|||
|
|||
RE: Resource leak in Java bindings | |||
12-07-2013, 03:20 PM
Post: #7
|
|||
|
|||
RE: Resource leak in Java bindings
(12-07-2013 03:18 PM)simoncn Wrote:(11-07-2013 01:53 PM)simonc Wrote: Thanks again. I've applied the patch as-is; it should be on github this evening. A separate change of mine broke the Windows-x64 build, blocking publication of the code. That problem is now fixed so I've manually pushed to github. Your changes are available there now. |
|||
15-07-2013, 02:21 PM
Post: #8
|
|||
|
|||
RE: Resource leak in Java bindings
(12-07-2013 03:20 PM)simonc Wrote: A separate change of mine broke the Windows-x64 build, blocking publication of the code. That problem is now fixed so I've manually pushed to github. Your changes are available there now. Thanks very much! I've downloaded the tag and confirmed that the problem is fixed. |
|||
« Next Oldest | Next Newest »
|