>I started up the SwingSet demo and noticed how slow it was. I ran
>top and noticed that even when I was doing nothing (i.e. no mouse
>moves, no selections, just sitting there) the demo was eating up
>16 MB of memory and 50-60% of my cpu. It seems as if the virtual
>machine never waits (at least when running this demo).
>
Because Swing is a fully lightweight library, it can't rely on any of the
operating-system-specific constructs underneath the JVM to more efficiently
make use of the CPU. Instead, it spins off a daemon thread to (basically)
poll the OS for the mouse position and information and broadcast that
information to the Swing JComponents under the mouse pointer at that
moment. Inefficient, yes, but that's what "Write Once, Run Anywhere" buys
you--necessary inefficiency sacrificed on the altar of portability. :)
I've never measured the CPU occupation of an AWT app, though; might be
interesting to run an AWT example and see if it takes up the same amount of
CPU. If not, then Swing's obviously doing things in the background that an
AWT app's not. (Maybe just filtering the events through all the event
listeners?)
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]