Am working on a swing app. I will experiance slowness after continuous half an hour of use.
can it because of GC running?
How can i find when the garbage collector runs through any jdk 1.5 commandline option?
Thanks
Am working on a swing app. I will experiance slowness after continuous half an hour of use.
can it because of GC running?
How can i find when the garbage collector runs through any jdk 1.5 commandline option?
Thanks
You can use jconsole.exe, which can be found in the bin directory of your jdk. It shows you a lot of details about your running JVM.
When you start Java with -XX:+PrintGC, it will print messages whenever it garbage-collects.
It's highly unlikely that the GC is causing observable problems. Once upon a time Java had a horribly slow GC that gave it a near-permanent bad reputation. That time is past.
What exactly is the slowness? A GC should really never take more than a fraction of a second, even for the rare full collection pass.
Edit: Even if the GC is running a measurable amount, it's likely only a symptom of the problem. Whatever code is placing that much demand on the GC would internally cause more slowness than the GC will.
I strongly doubt it's the GC you are seeing. As 280Z28 points out, the GC runs pretty fast usually (though can still kill performance if you're doing something wrong). Are you using the program in that time? If not, maybe you're a little low on memory and it got paged out? (leaving Eclipse running for longer than maybe half a day without using it results in a state I can't work anymore with it. On systems with little memory it might happen sooner).
The simplest way to investigate this if you use recent JDK is jvisualvm which allow you to attach to a running process. You can then see garbage collections, memory usage and profile if needed. (It is essentially the corresponding NetBeans functionality available as a standalone applciation in the JDK).
It complements and enhances jconsole!
(But what you describe may be excessive GC's caused by a memory leak in your program. Use jvisualvm to figure out)
GC itself probably is not the problem. However, if you have a memory leak, it might result in GC using all CPU trying to clear memory.
As everyone has mentioned previously, GC is almost certainly not the problem.
I'd try something like YJP (Your Java Profiler, free for 30 days) to profile your application and find out what is slowing down. A memory leak is a very possible cause.