I’m doing interactive development with Clojure and it would be great if I could start multiple jME apps in one JVM process for testing purposes. I don’t want to have to start a new JVM process for every client, because the JVM’s startup time is long. I tried it, and it didn’t seem to work, but maybe I was doing something wrong. Is it possible to start multiple jME apps in one JVM process?
It should be possible, but a lot of libraries assume that they are loaded only once.
Libraries that I know are critical in this regard are:
LWJGL - I think you can have multiplice Canvases, or possibly multiple Windows, but I have never tested this
Nifty GUI uses lots of global variables and is rather narrow about its assumptions, I wouldn’t be surprised if it utterly fails if you step outside Nifty’s expectations in this way.
You’d have to be very careful about initializing the global parts of each of these libraries just once, and reuse the globals (and JUST the globals) across all tests.
You’ll probably learn more about the libraries and their failure modes than you never wanted.
It would be a very worthwhile project to help ironing out the kinks of all the libraries. It wouldn’t be a fast route to production-ready software for you though, and probably quite the opposite. I guess whether you should try that depends on your goals.
A different approach would be using separate class loaders. “Globals” are created on a per-classloader basis in Java.
That would probably solve any problems with Nifty. I don’t know how LWJGL would interact with that; some of its code is written in C, and if the C side keeps global variables around, the classloader trick won’t help you.
@tuffe hi! i’m doing clojure development too! how is your project going?
from what i know, opengl can be rather restrictive on how many instances you can create due to its nature of interacting with the videocard. so using the headless mode, as proposed, may work for you, but first of all, why you want to have many instances of the application running on the same jvm? if you are for testing, then i would think there are two reaonable approaches: 1) use different physical machines to run every instance 2) factor out the part that requires testing into a separate entity and feel free to replicate these entities as much as you want… i assume that if you need to run that many instances of the application, then you no need the graphics part. if so, why not do tests inside a single app? especially if you’re on clojure. such an architecture would ony give benifits i think.
@tuffe: What do you think about comibining JMEs Controls and Clojure state/concurrency model? First I found them to be a little contradicting to each other, but after a while I just got used to some patterns where I use the both and all seems fine…