I had a quick look at the JNI library and I also don’t see any obvious
solution that does not require modifications to EPICS base.
Perhaps the next question is whether the proposed interface registering
for thread begin / exit callbacks should be implemented in (A) the CA
client library or (B) alternatively in epicsThread (see epicsThread.h).
I worry that it’s only a matter of time until we have more requests to
tightly integrate the Java VM within processes that might be running
EPICS. Perhaps it’s not a bad idea to, only when the Java VM is embedded
in a process that is also running EPICS, go with (B) and always bind the
VM to each and every EPICS thread that gets started. Since this would
occur only when the thread starts and stops presumably the overhead
would be minimal.
Furthermore, if we implement the epicsThread start / exit hook interface
I can also see a low overhead option using thread private variables that:
O attaches to the VM from within the JNI callback only the first time
that a JNI callback gets called by EPICS for a particular thread
O in the global epicsThread exit hook un-registers the current thread
with the VM only if it is currently registered with the vm
I could provide a pseudo code implementation for the 2^nd option if you
are interested.
I am thinking that the proposed interface belongs in epicsThread.
What do you think?
Jeff
------------------------------------------------------------------------
*From:* Matej Sekoranja [mailto:[email protected]]
*Sent:* Wednesday, October 18, 2006 12:03 PM
*To:* Jeff Hill
*Cc:* Ernest L. Williams Jr.; Thomas Pelaia II; Matej Sekoranja;
Kasemir, Kay; [email protected]; Andrew Johnson
*Subject:* Re: bug report
Hi,
On 10/17/06, Jeff Hill wrote:
Even if the memory leak is fixed by Sun, it would be desirable to fix
the JNI code so that it doesn't need to register/unregister the thread
(apparently a very high overhead call) from within every subscription
update callback? If there isn't a solution in the java support then
perhaps one possibility would be to provide a registration interface in
the ca client library specifying a user callback that gets run in the
context of a CA thread when it (the thread) starts and when it exists.
We might then register / unregister the thread with java from that call
back.