dagblog.
← Archive

It’s time for the multitasking virtual machine


Do your Java applications take a long time to start, use a lot of memory, and kill your memory budget if you run several? If so, all may be well yet. Sun’s labs researched and developed a Multitasking Virtual Machine, or MVM, under the code name Barcelona. It’s older news, admittedly, but interesting if you haven’t heard of the idea.

Normally, one Java application means one JVM. Each JVM has a heap, garbage collector, JIT compiler, standard class definitions and so on. Run two Java applications on your computer or any other device, a mobile phone for instance, and you get two completely independent JVMs. All the standard classes have to be compiled twice, and each JVM needs its own memory to hold the class definitions.

An MVM lets several Java applications run separately and independently inside one virtual machine. That makes it much more economical to run several applications. They share common classes, start faster and require less time to compile bytecode.

The main feature it uses is the Application Isolation API (JSR 121). Every running Java application is isolated from the others. They don’t interfere with each other. Calling System.exit(), for example, won’t shut down the whole MVM. Applications can’t tell whether they’re running in a conventional or multitasking VM, so you don’t have to change existing code.

Another part of the MVM is the Resource Management Interface, which lets you monitor and manage available resources such as CPU and memory.

The MVM has disadvantages too. Even with the isolation API, one application might still bring down the whole MVM by calling native code, for example. If the MVM crashes, every application inside it goes down too.

In many respects the MVM starts to resemble an operating system. That isn’t equally useful everywhere. I think it’ll find a place chiefly in enterprise and mobile environments, where it’s normal for several Java applications to run on the same system.

The benefit for desktop applications is debatable because Java never really caught on there. How many Java applications are still running on your desktop once you close the IDE and the application you’re developing? On the other hand, developers in particular could save memory and time and get a practical interface for managing system resources at different levels.

The Solaris MVM implementation for J2SE 5.0 is available as the Multi-Tasking Virtual Machine project on Java.net. If you have that OS, you can try running applications inside an MVM right away. An implementation is also available for CLDC (J2ME).

Sources

Medium version

Related articles

Related CZ Podcast episodes