You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Tim Ellison <t....@gmail.com> on 2006/09/26 19:20:14 UTC

[general] Multiple VMs running in a single process

We should bear in mind that applications may create multiple VM
instances per process, i.e. by calling JNI_CreateJavaVM multiple times,
and may choose to run the same classlib code on different VM instances
simultaneously.

In addition, applications are not obliged to exit the process after
destroying VMs to make them clean up <g>; so a couple of design points
to remember are:

- using global/static variables in native code is not a good idea unless
you intended the value to be shared across all VM instances.
The VMI has functions to set/get VM-local storage (VMLS) variables[1]
whose scope is a single VM instance. There is an example of their usage
here [2].

- when the VM is being destroyed it should free any resources it
allocated in the OS.  Similarly the class library code should release
any resources on shutdown.  Java code can use shutdownhooks to get
notification of exit, if there is any need for further native level
shutdown notification we can look at putting that into the VMI too.

[1]
http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/shared/hyvmls.h?revision=446492&view=markup
[2]
http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/archiveglob.c?revision=446478&view=markup


Regards,
Tim

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.



---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org