Restoring Swing applications after minimising

J

Jarrick Chagma

I would like to gauge people's experiences with Swing applications on
various platforms. I mainly use Windows platforms for development and
running Java applications and I find that Swing applications really don't
like being minimised for any length of time. If I leave a Swing application
alone (particularly a large app like NetBeans) for about 10 minutes or more
in a minimised state and then try to restore it, it will usually take a long
time to become responsive again during which time there is a lot of disk
activity. On a slow machine this can take a minute or longer.

I realise this is related to Windows itself swapping out some memory that
the app is using but why does it only happen with Swing apps? I have tried
setting the JVM parameter sun.awt.keepWorkingSetOnMinimize to true but this
only helps in a minor way. This problem does not seem to affect SWT apps
like Eclipse which always responds almost immediately after being minimised
so what makes Swing apps so vulnerable to this problem?

I would also like to know if it is a Windows-only problem or does it happen
on Linux or the Mac as well?

Also, is there some way to resolve this issue on Windows other than setting
sun.awt.keepWorkingSetOnMinimize?

Looking through previous threads on this subject it seems that I am risking
being accused of trolling for evoking comparisons between Swing and SWT and
also that most people just don't seem to see this issue as a significant
problem. Why not? I find it exceedingly annoying to have to wait for a
Swing app to respond after being restored when all other Windows
applications pretty much start being responsive immediately. This behaviour
contributes to Swing apps being seen as slow by many people and also
negatively affects the standing of Java apps in the community in general.
 
L

Lew

Jarrick said:
I would like to gauge people's experiences with Swing applications on
various platforms. I mainly use Windows platforms for development and
running Java applications and I find that Swing applications really
don't like being minimised for any length of time. If I leave a Swing
application alone (particularly a large app like NetBeans) for about 10
minutes or more in a minimised state and then try to restore it, it will
usually take a long time to become responsive again during which time
there is a lot of disk activity. On a slow machine this can take a
minute or longer.

Wasn't nearly this exact question posted a while back? I seem to recall that
this was not everyone's experience.

I also have seen behavior under Windows such as you describe on programs that
don't use Swing, or even Java.
I realise this is related to Windows itself swapping out some memory
that the app is using but why does it only happen with Swing apps? I
have tried setting the JVM parameter sun.awt.keepWorkingSetOnMinimize to
true but this only helps in a minor way. This problem does not seem to
affect SWT apps like Eclipse which always responds almost immediately
after being minimised so what makes Swing apps so vulnerable to this
problem?

I have used Eclipse-based IDEs for years; I don't notice them taking more or
less time than, say, NetBeans to become responsive under Windows.
I would also like to know if it is a Windows-only problem or does it
happen on Linux or the Mac as well?

I doubt that it's even a Windows problem, that is to say, that Swing apps
behave differently under Windows in this regard than other Java or non-Java apps.;
Also, is there some way to resolve this issue on Windows other than
setting sun.awt.keepWorkingSetOnMinimize?

Looking through previous threads on this subject it seems that I am
risking being accused of trolling for evoking comparisons between Swing
and SWT and also that most people just don't seem to see this issue as a
significant problem. Why not?

Probably because we are not seeing the phenomenon at all.
I find it exceedingly annoying to have
to wait for a Swing app to respond after being restored when all other
Windows applications pretty much start being responsive immediately.
This behaviour contributes to Swing apps being seen as slow by many
people and also negatively affects the standing of Java apps in the
community in general.

Does it? Does it really?
 
Q

Qu0ll

Lew said:
Wasn't nearly this exact question posted a while back? I seem to recall
that this was not everyone's experience.

I have asked a similar question a few times over the years and, yes, the
upshot was always that other people didn't experience it or that it wasn't
seen as very worrying when they did.

It's nice to know that someone else is also concerned by this issue but
clearly it is not very prevalent.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]
 
L

Lew

Qu0ll said:
I have asked a similar question a few times over the years and, yes, the
upshot was always that other people didn't experience it or that it
wasn't seen as very worrying when they did.

It's nice to know that someone else is also concerned by this issue but
clearly it is not very prevalent.

Is there even really an issue?

Delays, perceived or real, in un-minimizing a Windows program are highly
dependent on extrinsic factors - what other programs are running? What are
they doing? What is the amount of swap space? How full or fragmented is the
disk? What exactly is the app doing when it's unminimized? If it's a GUI app
such as a Swing app, is it properly written to move long-running tasks off the
EDT? How much memory is on the machine? How much network traffic? Did there
just happen to be a GC run in the JVM at that moment? Are they talking about
a particular Swing app each time? What was the state of mind of the person
claiming a delay? Have they actually measured the time and compared it to
non-Swing or non-Java apps under controlled conditions?

When people say something like, "Swing apps take a long time to get responsive
when they're unmiminized", they never lock down these factors.

Studies have shown that people will often report a program as being faster at,
say, initial startup even if it's actually slower compared to a control.
Factors such as a splash screen can reduce the perceived time even when the
clock time is longer.

The question as phrased by the OP was far too vague and loaded to even begin a
meaningful discussion. There needs to be objective evidence.
 
A

Andrew Thompson

...
Is there even really an issue?

'Possibly'. I noted a thread on the Sun forums which
linked to bug reports, and commented that the behaviour
of Swing apps. when interacting with the Windows 'swap
file' could cause the behaviour described. The poster
commented that they found a fix for it - to add a
WindowListener and call System.gc() whenever the frame
was minimized.

Unfortunatley, I did not bookmark the thread, but
intended to do further investigation, as the reporter
was someone who's advice I held in high regard (and no,
I cannot even recall who that was).
 
J

Jarrick Chagma

Lew said:
Is there even really an issue?

Delays, perceived or real, in un-minimizing a Windows program are highly
dependent on extrinsic factors - what other programs are running? What
are they doing? What is the amount of swap space? How full or fragmented
is the disk? What exactly is the app doing when it's unminimized? If
it's a GUI app such as a Swing app, is it properly written to move
long-running tasks off the EDT? How much memory is on the machine? How
much network traffic? Did there just happen to be a GC run in the JVM at
that moment? Are they talking about a particular Swing app each time?
What was the state of mind of the person claiming a delay? Have they
actually measured the time and compared it to non-Swing or non-Java apps
under controlled conditions?

When people say something like, "Swing apps take a long time to get
responsive when they're unmiminized", they never lock down these factors.

Studies have shown that people will often report a program as being faster
at, say, initial startup even if it's actually slower compared to a
control. Factors such as a splash screen can reduce the perceived time
even when the clock time is longer.

The question as phrased by the OP was far too vague and loaded to even
begin a meaningful discussion. There needs to be objective evidence.

Lew, the intention of my post was not to state scientific results; I was
merely trying to gauge the general opinion of Swing users on various
platforms. While I have definitely not tried to accurately measure the
various times it takes all manner of applications to become responsive after
minimising, I cam certainly not imagining it when I say that Swing
applications take much longer than native applications, at least on the
Windows machines that I have used over the past few years. I don't need to
do a full-blown scientific study to know that. There doesn't need to be
"objective evidence" when all I am asking for is a "feeling" and, let's face
it, feelings are important to many people when a they decide what software
to purchase or even to use (whether they should be or not is of course
another matter).

You seem to be using the age-old dismissive argument of "it works fine for
me and therefore there is no problem". I can categorically state that I
have seen the behaviour I have described on a number of Windows machines
using the latest Java versions on Windows XP and Vista at least, machines
with up to 4GB of RAM and plenty free at the time. The fact that it doesn't
happen on your machine says absolutely nothing about my machine or anyone
else's for that matter. I am happy for you Lew but, really, your "it works
fine for me" claims are no more scientific than mine.
 
R

Roedy Green

If I leave a Swing application
alone (particularly a large app like NetBeans) for about 10 minutes or more
in a minimised state and then try to restore it, it will usually take a long
time to become responsive again during which time there is a lot of disk
activity. On a slow machine this can take a minute or longer.

I have not used NetBeans for quite some time. I use IntelliJ Idea
which is a similar large Java IDE. I don't have that problem. I am
using Vista Home premium. I have 4 Gigs of DRAM and 4 gigs of
Readyboost USB flash RAM.
See http://mindprod.com/bgloss/readyboost.html

My hard disk is SATA-3. Buffer is 8 MB. Average seek 8 ms. Max
transfer rate 300 Mbytes per second. Windows rating 5.3.

I am fanatical about keeping my disks defragged, including the
registry and the pagefile.
See http://mindprod.com/jgloss/defragger.html I use O&O (and Paragon
to compact the MFT).

Ace utilities will prune the registry of deadwood, and compact it.
see http://mindprod.com/jgloss/registrycleaner.html

You can very cheaply add 4GB of Readyboost, maybe even free, since USB
drives are being handed out the way keychains used to be as
advertising gifts. You can download any defragger and use it for a
month free too see if that helps, ditto for registry
cleaner/compactors.

About the only expensive thing to try is a faster hard disk.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"If people become accustomed to lying, they will unconsciously commit every possible wrong deed. Before they can act wickedly, they must lie, and once they begin to lie they will act wickedly without concern."
~ Gautama Buddha
 
L

Lew

Andrew said:
'Possibly'. I noted a thread on the Sun forums which
linked to bug reports, and commented that the behaviour
of Swing apps. when interacting with the Windows 'swap
file' could cause the behaviour described. The poster
commented that they found a fix for it - to add a
WindowListener and call System.gc() whenever the frame
was minimized.

Of course, System.gc() is not guaranteed to do anything, but at least one can
figure that at minimization time it will do no harm.
 
L

Lew

Jarrick said:
Lew, the intention of my post was not to state scientific results; I was
merely trying to gauge the general opinion of Swing users on various
platforms. While I have definitely not tried to accurately measure the
various times it takes all manner of applications to become responsive
after minimising, I cam certainly not imagining it when I say that Swing
applications take much longer than native applications, at least on the
Windows machines that I have used over the past few years. I don't need
to do a full-blown scientific study to know that. There doesn't need to
be "objective evidence" when all I am asking for is a "feeling" and,
let's face it, feelings are important to many people when a they decide
what software to purchase or even to use (whether they should be or not
is of course another matter).

You seem to be using the age-old dismissive argument of "it works fine
for me and therefore there is no problem". I can categorically state
that I have seen the behaviour I have described on a number of Windows
machines using the latest Java versions on Windows XP and Vista at
least, machines with up to 4GB of RAM and plenty free at the time. The
fact that it doesn't happen on your machine says absolutely nothing
about my machine or anyone else's for that matter. I am happy for you
Lew but, really, your "it works fine for me" claims are no more
scientific than mine.

My "it works fine for me" statement was a direct response to your request to
"gauge people's experiences" on the matter. If you didn't want people's
experience, why did you ask for it?

Furthermore, evidence is by its very nature scientific. The fact that others
have not observed what you are categorically averring to be a "problem" that
"only happen with Swing apps" is contrary evidence.

On top of that, it only takes one counterexample to disprove an hypothesis.

Calling evidence "dismissive argument" is rhetorical and non-scientific. I
provided evidence that what you described is not universally experienced.
That is all.

Rejecting evidence that contradicts one's hypothesis is the very epitome of
unscientific behavior.
 
L

Lew

Lew said:
Is there even really an issue
[with slow Swing response when an app is restored from minimized]?

Andrew said:
'Possibly'. I noted a thread on the Sun forums which
linked to bug reports, and commented that the behaviour
of Swing apps. when interacting with the Windows 'swap
file' could cause the behaviour described. The poster
commented that they found a fix for it - to add a
WindowListener and call System.gc() whenever the frame
was minimized.

Unfortunately, I did not bookmark the thread, but
intended to do further investigation, as the reporter
was someone who's advice I held in high regard (and no,
I cannot even recall who that was).

This provides evidence, if borne out by further investigation, that there
might be an issue with GC occurring on restore (in MS Windows only?) that
interferes with GUI responsiveness.
 
L

Lew

Roedy said:
You can download any defragger and use it for a
month free too see if that helps, ditto for registry
cleaner/compactors.

MS Windows includes a disk defrag utility.
 
J

Jarrick Chagma

[...]
My "it works fine for me" statement was a direct response to your request
to "gauge people's experiences" on the matter. If you didn't want
people's experience, why did you ask for it?

I *do* want people's experiences. I *don't* want people saying that the
problem doesn't exist at all because it doesn't happen to them.
Furthermore, evidence is by its very nature scientific. The fact that
others have not observed what you are categorically averring to be a
"problem" that "only happen with Swing apps" is contrary evidence.


I don't believe I am the only one experiencing this.
On top of that, it only takes one counterexample to disprove an
hypothesis.

My hypothesis is that, in general, Swing apps take longer to become
responsive after restoring than native apps. One counter-example does not
disprove that.
Calling evidence "dismissive argument" is rhetorical and non-scientific.
I provided evidence that what you described is not universally
experienced. That is all.

I don't believe I ever said it was "universal".
Rejecting evidence that contradicts one's hypothesis is the very epitome
of unscientific behavior.

As I said, I am not rejecting your evidence, it does not disprove my
hypothesis and I am not trying to be rigorously scientific about this anyway
as yet. When I sense that there is a general feeling to support my
hypothesis I might do some formal testing to prove it.
 
L

Lew

Jarrick said:
I *do* want people's experiences. I *don't* want people saying that the
problem doesn't exist at all because it doesn't happen to them.

No one here has asserted that the problem does not exist. So you didn't get
what you don't want.

I did assert that there needs to be objective evidence of such a problem in
order to claim that it does exist. I don't know how anyone can disagree with
that.

I also suggested alternative explanations, and asserted that I might've seen
slow responses upon unminimization of non-Swing applications. I cannot be
sure, because I have not measured such responses and have no objective sense
of what can be considered "slow", and because response time is affected by the
plethora of factors I outlined above. Nevertheless, in the context of your
original question that seems valid and relevant.

I do doubt that the problem exists exactly as you stated it - that Swing apps
particularly, under MS Windows perhaps, take longer to unminimize than other
types of apps. "Doubt" by definition is a probabilistic prediction and not a
firm statement of conviction.
<http://en.wiktionary.org/wiki/doubt>

I will hardly be devastated if proven wrong in my doubt ("uncertainty",
"disbelief").

I find it peculiar and unnecessary for anyone to take umbrage at statements
that provide relevant evidence, alternative explanations, and suggestions as
to how to strengthen the investigation.
 
J

Jarrick Chagma

Lew said:
No one here has asserted that the problem does not exist. So you didn't
get what you don't want.

I did assert that there needs to be objective evidence of such a problem
in order to claim that it does exist. I don't know how anyone can
disagree with that.

I also suggested alternative explanations, and asserted that I might've
seen slow responses upon unminimization of non-Swing applications. I
cannot be sure, because I have not measured such responses and have no
objective sense of what can be considered "slow", and because response
time is affected by the plethora of factors I outlined above.
Nevertheless, in the context of your original question that seems valid
and relevant.

I do doubt that the problem exists exactly as you stated it - that Swing
apps particularly, under MS Windows perhaps, take longer to unminimize
than other types of apps. "Doubt" by definition is a probabilistic
prediction and not a firm statement of conviction.
<http://en.wiktionary.org/wiki/doubt>

I will hardly be devastated if proven wrong in my doubt ("uncertainty",
"disbelief").

I find it peculiar and unnecessary for anyone to take umbrage at
statements that provide relevant evidence, alternative explanations, and
suggestions as to how to strengthen the investigation.

Umbrage? I thought we were just having a lively, friendly chat. Don't get
me wrong Lew, I greatly appreciate your input on this. If you didn't mean
to suggest that the problem doesn't exist at all then I must have
misinterpreted your remarks. Whatever, there is no umbrage taken here!

I look forward to the input of other Swing users but I doubt there will be a
lot of that given that most people don't seem to notice or mind that Swing
apps are a bit sluggish after being restored. I base that remark on Qu0ll's
and other's previous attempts to raise this issue.
 
R

Roedy Green

Lew, the intention of my post was not to state scientific results; I was
merely trying to gauge the general opinion of Swing users on various
platforms.

Swing is much fatter that AWT, so of COURSE it will be not perform
well in a RAM-tight situation. The question is just how many
resources do you need to throw at it to get acceptable performance.

With a GUI, as long is it can keep up with your typing and scrolling,
there is not much point in still improved performance. Yet anything
less than that is annoying. It is a threshold you have to get over.

I have a dual core machine which tends to make GUI code perform more
smoothly and consistently.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Everybody’s worried about stopping terrorism. Well, there’s a really easy way: stop participating in it."
~ Noam Chomsky
 
C

charlesbos73

Is there even really an issue?

Lew...

There's nothing in the JLS that talks about this.

Hence it doesn't exist.

You can refrain to comment on posts where you
cannot answer with your one-liner "see JLS a.b.c.
and use ORM technology 'x'".
 
C

charlesbos73

You seem to be using the age-old dismissive argument of "it works fine for
me and therefore there is no problem".

Lew is actually using a lot of logical fallacies in various
of his posts and a lot of ad nominem attacks.

As soon as he cannot quote the JLS he's lost. He made a fool
of himself on quite some occasions on subjects where he couldn't
lookup a quick quote from the JLS or from Effective Java of
from JCIP.

The worst intellectual dishonesty I've seen from him was an
answer where he said he didn't like to "swim with the stream"
(I'm paraphrasing, maybe it was "follow the stream") to a
poster that was suggesting a clearly non-mainstream technique.

Don't forget that it will also nitpick on english spelling
and grammar mistakes (which is laughable in a newsgroup
where non-native english speakers --like myself-- participate).

Actually a bot that would take first post and do a search
in the JLS on a few terms and quote the JLS in condescending
terms like:

"You should try to read J.L.S. x.y.z."

could probably be easily programmed and it would sound
very much like Lew's response.

The only reason you know that the JLS doesn't contain
a paragraph like "If your email starts with lew and
ends with cannons.com, jump in front of a train" is
because he's still posting in here.

Java is the holy grail and the JLS is the gospel.

Everything in Java was done right, and there are no
issues at all.

Not to mention he's never been involved in a project
involving client side Swing code deployed on various
architectures nor in server-side code involving an OO DB.

Don't pay attention to him. He's a "JLS nazi" and a
lot of his aggressive posts are borderline trollish.

He happens to have found some audience that gives him
some credibility because he can quickly search and
quote the JLS (which is convenient btw when you're too
lazy to search the JLS, you can simply query "Lew the
JLS-nazi bot").

He's emotionally invested in arguing with anything that
is outside his area of expertise (which seems pretty
limited to using Java in a procedural style to query
SQL DBs).

To the OP: see my other post regarding that issue you're
experiencing and a possible workaround (heresy: a constructive
post looking for an actual workaround instead of nitpicking
because "Java is perfect, so is Swing, every feature in Java
is there for a reason and must be used, I can quote you the
JLS to tell you how it works").
 
L

Lew

There's nothing in the JLS that talks about this.

Hence it doesn't exist.

Well, that was a totally irrelevant and unhelpful remark.

Others have observed, as have I, that slow startup after long minimization
occurs with non-Swing programs, such as Eclipse and non-Java programs.

The phenomenon seems to be a Windows issue. As RedGrittyBrick suggested, it
might be related to the amount of memory a Windows program uses. Java and
Swing require a lot of memory, which might account for the observed patterns.
 
C

charlesbos73

No one here has asserted that the problem does not exist.

Lew: Is there even really an issue?
....
Lew: Studies have shown that people will often report a program
Lew: as being faster at, say, initial startup even if it's actually
Lew: slower compared to a control. Factors such as a splash screen
Lew : can reduce the perceived time even when the clock time is
longer.

Why do I have the feeling that most of your posts are bordeline
trollish and that you use many little dirty intellectual tricks
to drag the discussion exactly where you want to?

Reading your first answer to the OP I had the *exact* same feeling
as the OP.

Realize that your anal way of thinking is not necessarly appreciated
by everyone in here and that some people don't consider you smart
in here. I only, at best, consider you a smart-ass (you're definitely
anal) JLS-nazi and that's it.


Lew: The question as phrased by the OP was far too vague and loaded to
Lew: even begin a meaningful discussion.

Then, please, refrain from trolling those threads you consider
unmeaningful.
 
C

charlesbos73

I realise this is related to Windows itself swapping out some memory that
the app is using but why does it only happen with Swing apps? I have tried
setting the JVM parameter sun.awt.keepWorkingSetOnMinimize to true but this
only helps in a minor way. This problem does not seem to affect SWT apps
like Eclipse which always responds almost immediately after being minimised
so what makes Swing apps so vulnerable to this problem?

While working on some Swing software that had one "main" window, that
could be minimized, and other windows (JFrames) that would always stay
visible and on top of the other applications's windows, I noticed
something
similar... Only when the JFrames weren't there.

It's something we noticed during development, where we'd typically
sometimes
launch the program, minimize it then leave it minimized for some time.

When we were bringing up the minimized (main) window, it would come up
faster
when at least one of our JFrame "visible and always on top" was there.

If you really want to force that behavior (faster un-minimizing) you
*could*
try to create a borderless, one-by-one, visible, fully transparent and
always
on top JFrame just to see if it solves your problem.

MacOS X has Java transparency since always and JDK 1.6.0_10 has
transparency.

At worst you could try with a 1x1 non-transparent JFrame.

I'm not advocating to use this as a workaround for production code,
but it could
be interesting to try out if the behaviour you're describing is
reproducible, to
see if that lag goes away or not.

Once again I realize suggesting to do experiments is heresy flying in
the face of logical reasoning. But seen that the "JLS-nazi bot" is
himself resorting to dirty intellectual tricks I'm not afraid of my
suggestion.



P.S: I qualify writing "Did you try to read ..." instead of "Did you
read"
as a dirty little intellectual trick. The JLS-nazi bot has become
a master in manipulating such dirty little intellectual tricks.

P.P.S.: Don't bother reading the JLS-nazi bot's answers on anything
that
cannot be answered by a direct JLS quote.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top