Chris Oliver's Weblog
- All
- F3
- JavaFX
- Programming
- Research
Poor man's Multi-VM
The most recent demos on my weblog are run as separate applications in the same JVM. In addition to its own F3 interpreter, each individual demo gets its own class loader, thread-group, and AWT event-dispatch thread. This is accomplished by using features also used in the applet plugin. Note that this approach isn't specific to F3, but could be used with any Swing application. You can manually kill the applications (which is implemented in the same way that applets are destroyed when you leave a web page). In addition, it installs a security manager that traps System.exit() and destroys the application context of the application rather than exiting the JVM. Some of the F3 demos may appear to start slowly, but that's due to the overhead of F3 or to the fact that many images are being loaded from the network or file system, and not due to the JVM. Self-contained Swing apps (such as SwingSet2) would start instantaneously.
I was prompted to do this by Gilad Bracha (who unfortunately left Sun recently). Gilad told me that he didn't believe in Java GUI's for two reasons:
- Start-up time
- Footprint
He mentioned a test they did comparing the SmallTalk Squeak IDE, which started up in about 3 seconds and used about 25M of memory, compared to Netbeans which in this test took a minute to start up and used over 100M. But of course you may not consider this a fair test. So next they simply took a screenshot of the Squeak IDE and then wrote a tiny Java program just to display the screenshot. This second program took 3 seconds to start up and also used about 25M of memory, but in the first case we had a fully-functioning SmallTalk IDE and in the other just a bitmap.
I personally found his arguments undeniable.
I did my own tests where I ran 10 instances of SwingSet2 in separate JVMs versus in the same JVM but with separate application contexts. In the former case total memory use was 540M, in the latter 74M.
As I mentioned this approach isn't specific to F3.
I put a zip file containing the basic code to do this for regular Swing applications here (45kb).
Note: this is just example code to illustrate how you could do this.
The zip file contains the source and compiled code and some windows batch files to build and run it (Java 1.6 required to build, Java 1.5 to run).
There's only one class called JApplication. You call its main method with a class path and class name similar to how you run the java command, e.g.
java com.sun.JApplication -classpath SwingSet2.jar SwingSet2
When you run it the first time it creates a server socket on the local host and listens for subsequent connections. At the same time it creates a new thread group, class loader, and application context and runs the application you specified (i.e in this case SwingSet2). When you run it subsequent times it simply connects to the port and writes the command line argument over the socket. The original then creates a new thread group, class loader, and application context as above and runs it in the address space of the original vm. In addition, writes to System.out and System.err from that thread group are redirected back to the socket so you see the console output of your application as expected. It would also be possible to write a C program or shell script to launch your application (rather than using another JVM).
Finally, if you're using Java 1.6 it adds an icon to the system tray which has a menu to shut down the whole thing and also can display a window listing the running applications and which allows you to kill them manually.
Note that this example code doesn't handle security issues at all.
Posted at 09:51AM Nov 29, 2006 by Christopher Oliver in F3 | Comments[53]
Posted by Neil Corlett on November 29, 2006 at 10:48 AM PST #
Posted by releaseit on November 29, 2006 at 05:06 PM PST #
Posted by Patrick Wright on November 30, 2006 at 06:05 AM PST #
Posted by evanx on December 01, 2006 at 12:55 AM PST #
Posted by Chris Oliver on December 01, 2006 at 10:33 AM PST #
Sorry, but your writeup is incomplete without an explanation of the observed behaviour. For that if it matters, I've seen complete 32 bit Windows GUI programs that were less than 25KB in size. (They were coded in assembly).
The issues are closely related to what each of the approaches are trying to accomplish and with what philosophy.
Java, with Swing, tries to bring a cross-platform GUI toolkit. However, it fails to live up to the "instant on" crowd's expectations because of what I believe were philosophical decisions taken in development of Swing and Java implementation.The JVMs do not even try to optimize the load times. The JIT kicks in late after profiling, JAR caching etc are ideal for applications whose run time is much longer than startup time, but little else.
Secondly, the Swing approach of virtualizing everything on the canvas and only using the least common denominator OS services had its own advantages and disadvantages. Advantages were more in line with consistency (though in practice it became equally-inconsistent) and customizable & richer widget set. I also believe they would have thought about the programming model too, now that it wasn't tied to particular ways different OSs try to do GUI (eg. multi/single thread event dispatching etc etc) and I believe they'd have thought about a lot of other possibilities, which would have been axed for being too "futuristic" and "out-of-ordinary".
So I do believe Swing designers were upto something, and not just plain wrong. The objectives ended up being different from expectations of "lean-mean" and "instant-on" crowds... but well, it's all not that bad too :-)
PS: I'm shocked to see Gilad leaving too. What is Jonathan doing ????
- AkhileshPosted by Akhilesh Mritunjai on December 02, 2006 at 06:05 AM PST #
Posted by Vinay Soni on December 03, 2006 at 10:54 PM PST #
Posted by evanx on December 04, 2006 at 02:10 PM PST #
Posted by Andy White on December 05, 2006 at 05:29 AM PST #
Posted by Deniz Oguz on December 06, 2006 at 11:03 PM PST #
Posted by Evan Summers's Blog on December 10, 2006 at 12:54 PM PST #
I'm curious if in your "10 JVMs" test whether you simply added up the process memory each process reported, or did you consider, and subtract, the amount of shared memory the JDK 5 Class Sharing system shared across all 10 JVMs.
It's my understanding that the class sharing is designed to address this specific concern in terms of excess resource usage.
But that's not readily apparent from simply adding up the combined process sizes, as they each report what is in fact shared memory.
Posted by Will on December 11, 2006 at 04:24 PM PST #
Posted by 71.195.202.79 on December 11, 2006 at 09:35 PM PST #
Posted by Chris Thiessen on December 13, 2006 at 07:05 AM PST #
From one of the quotes above:
I don't think the philosophical decisions were that different from those of the commercial Smalltalk VisualWorks. They both provide their own GUI toolkits that are platform independent and use them to simulate the platform they start up on. VisualWorks Smalltalk has done cross-platform GUI's since 1994 or so. The applications are faster at starting up and have a smaller memory footprint than an equivalent Java application. What you trade though is all the security and sandboxing, but for a desktop application, you aren't typically loading class files over the internet, etc.
The VW VM is very competitive in performance even with the latest Java releases including HotSpot and uses many of the same techniques, which if you have read about Strongtalk, that were originally aimed at Smalltalk and were then retargeted to Java after SUN bought the company.
IMO, VisualWorks is still a leader when you talk about powerful, crossplatform GUI frameworks. It was and is a truely write-once run everywhere. (Excluding custom C extensions for which Java has the same issue). VisualWorks is a very competitive Cross Platform development environment supporting DB's, Web Services, Distributed Programming, CORBA, etc.
You can learn more here: Cincom Smalltalk
Having said all that, this work on F3 is exciting and very relavant to the needs of real developers.
Posted by Sam Griffith Jr on December 14, 2006 at 03:30 AM PST #
That said, many thanks for F3 and also for pushing the limits of classloader-based containers with JApplication!
Posted by sbohne on January 12, 2007 at 07:52 AM PST #
Hi, Chris.
Two quickies:
1) What license is JApplication released under?
2) Spotted a small bug: the classloader cache lookup always fails as it's using String[] keys. Changing these to use the "urls" linked lists fixes this.
Posted by chocolateboy on February 18, 2007 at 12:28 AM PST #
Thank you
Posted by ankara evden eve on September 12, 2008 at 02:53 AM PDT #
Hank tahnks
Posted by abiyeler on September 12, 2008 at 02:55 AM PDT #
thank you.
Posted by ankara evden eve nakliyat on October 01, 2008 at 12:43 PM PDT #
very nice...
Posted by evden eve nakliyat on October 26, 2008 at 02:14 AM PDT #
nice. tahnsk
Posted by evden eve nakliyat on October 26, 2008 at 02:15 AM PDT #
Pretty nice gallery!
Nice site. Thank you
<a href="http://www.nakliyatankara.net" title="sehirler arası nakliyat" target="_blank">sehirler arası nakliyat</a>
<a href="http://www.ankaranakliyatrehberi.com" title="ankara evden eve nakliyat" target="_blank">ankara evden eve nakliyat</a>
<a href="http://www.nakliyatankara.net" title="evden eve tasimacilik" target="_blank">evden eve tasimacilik</a>
<a href="http://www.nakliyatankara.net" title="ankara evden eve nakliye" target="_blank">ankara evden eve nakliye</a>
<a href="http://www.ankarnakliyee.com" title="ankara evden eve nakliye" target="_blank">ankara evden eve nakliye</a>
Posted by ankara evden eve nakliyat on January 28, 2009 at 10:18 PM PST #
thanx
Posted by evden eve nakliyat on June 18, 2009 at 09:57 AM PDT #
The second programm needs more than 25 MB on my pc
Posted by Stefan G. on November 20, 2009 at 08:04 AM PST #
Örnek Alüminyum sektörün önde gelen firmasıdır. 1985 yılında Konya'da başlayan alüminyum satışlarımız her yıl artarak devam etmektedir.
Posted by Örnek Alüminyum Sistemleri on November 21, 2009 at 04:09 AM PST #
thank you
Posted by jammer on November 24, 2009 at 01:01 AM PST #
Great post thanks
Posted by jammer fiyatları on December 06, 2009 at 06:16 PM PST #
Very informative post thank you admin.
Posted by telefon dinleme on December 06, 2009 at 06:17 PM PST #
Good post . Thank you for the comment.
Posted by dinleme cihazları on December 06, 2009 at 06:18 PM PST #
Casus cep telefonu yazılımları casus telefonlar telefon dinleme programları.
Posted by casus telefon on December 06, 2009 at 06:21 PM PST #
Ses kayıt cihazları casus ses kayıt programı dinleme ve takip
Posted by ses kayıt cihazı on December 06, 2009 at 06:23 PM PST #
A violet-colored soil is born,
Compassion wing ger, such as man …
One promised in the realm of spirits,
You’re giving back to the words, such as man …
Yours is wet stone hearts in
Hopes disappear in rose petals,
Friends can be lying in the market,
Find immortal man, as man …
Dessert at the end of every day,
This loop has a price in life,
If the name of Islamic identity, the
Into account the self-check, such as man …
Can bodies are entrusted in the country,
When people are shot in coffee,
A wounded bird fluttering on the soul,
Into the grave without dying, like the man …
Who on earth you’ve visited?
You benefit from all those who favor?
Read the call to prayer, the bells play who?
Bedtime each day thinking, man, like …
Although the load hit the back waist,
She goes to lie rızkım,
The head upright, these are the essence to comply,
Anyone submission, such as man …
Ben seni;
I dropped all the masks, the
In the purest form of my emotions,
Deceive myself from
Do you mind I see someone without
I shed tears as I liked …
Sometimes I felt myself weak,
Sometimes solitary,
My dough is already my heart,
And every drop of my eyes was a charity,
I pray to Allah, while you,
I shed tears as I liked …
Words can not describe the trouble sometimes,
Get ya self one is condemned to silence,
Where the last bit of lyrics HOPE,
I’ve shed my tears I love you like …
Posted by Toner Arsivi on December 16, 2009 at 07:24 AM PST #
ridos
Posted by karadeniz turları on December 23, 2009 at 10:02 AM PST #
imza
Posted by bilgisayar on December 23, 2009 at 10:02 AM PST #
Good post . Thank you for the comment.
Posted by çizgi film on December 28, 2009 at 09:23 AM PST #
we only require 2d, 3d, and 4d vectors and 2x2, 3x3, and 4x4 matrices. These types are provided in a new package called javafx.math, http://www.watchgy.com/ namely Vec2, Vec3, Vec4, Mat2, Mat3, Mat4. Since rotations may be represented as a pair of angle/axis, or quaternion form, in addition to matrix form, we also provide the types AngleAxis, and Quat. http://www.watchgy.com/tag-heuer-c-24.html
http://www.watchgy.com/rolex-submariner-c-8.html
http://www.watchgy.com/rolex-daytona-c-6.html
Posted by rolex submariner on December 29, 2009 at 06:11 AM PST #
Good post . Thank you for the comment.
Posted by dinle on January 02, 2010 at 09:41 AM PST #
Good post . Thank you for the comment.
Posted by film seyret on January 02, 2010 at 09:41 AM PST #
Good post . Thank you for the comment.
Posted by örgü on January 02, 2010 at 09:42 AM PST #
Good post . Thank you for the comment.
Posted by resimler on January 02, 2010 at 09:42 AM PST #
Good post . Thank you for the comment.
Posted by oyun oyna on January 02, 2010 at 09:43 AM PST #
Good post . Thank you for the comment.
Posted by oyun gemisi on January 02, 2010 at 09:43 AM PST #
Good post . Thank you for the comment.
Posted by mp3 indir on January 02, 2010 at 09:43 AM PST #
Good post . Thank you for the comment.
Posted by tedavisi on January 02, 2010 at 09:44 AM PST #
Good post . Thank you for the comment.
Posted by hastalık on January 02, 2010 at 09:45 AM PST #
<a href="http://www.piriltinakliyat.com" title="ankara nakliyat" target="_blank">ankara nakliyat</a> ve
<a href="http://www.aba-temizlik.com" title="ankara halı yıkama" target="_blank">ankara halı yıkama</a> ayrıca evden eve <a href="http://www.piriltinakliyat.com" title=" nakliyat" target="_blank"> nakliyat</a>
Posted by metin gül on January 14, 2010 at 10:55 AM PST #
http://www.piriltinakliyat.com/
Posted by ankara evden eve on January 14, 2010 at 10:58 AM PST #
it is so good~1
Posted by Louis Vuitton bags on January 30, 2010 at 12:56 AM PST #
thanks
http://emlakx.net
http://emlakx.net/haberler
http://emlaksay.com
http://parcakontor1.com
http://saays.com
http://arslantekniksogutma.com
http://cerkezkoyemlakofisi.com
Posted by emlak ilanları on January 30, 2010 at 04:55 AM PST #
Good post . Thank you for the comment.
Posted by Alice on January 30, 2010 at 12:11 PM PST #
I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
Posted by replica rolex on January 31, 2010 at 07:42 PM PST #
<a href="http://www.afbk-fx.cn/">外汇</a>保证金交易是利用外汇而进行的交易
环球外汇交易 在世界最受欢迎的<a href="http://www.afbk-fx.cn/">外汇交易</a>
<a href="http://www.138le.com/">招聘销售</a>
<a href="http://www.138le.com/">招聘兼职</a>
Posted by 我发财 on February 02, 2010 at 04:39 AM PST #