General questions about Java Garbage Collection
First off I'd like to begin saying that I'm new to these forums, but am glad to be here. This seems like a professional and friendly community. Now, a little background: I know the basics of Java, inheritance, interfaces and such, as well as the basics of GUI design and programming with Netbeans IDE and the Swing toolkit, but I am not a professional Java developer, more of an on and off hobbyist. But, I do work professionally with a language that is built on top of Java, which I've been using for the past three years. The language provides mechanisms to use any object that is accessible to Java, or any class, which is a pretty cool feature. But, over the course of time, we've had ocassions when our main application made in this language will freeze up and freeze every user connected to it. On other occassions, the whole thing feels sluggish. At first, stuff like this happened all the time. After we contacted the company which makes the language we use (basis.com), they suggested that we change the -Xmx and -Xms parameters in thr JVM which runs our application. We adjusted these parameters to the numbers they recommended, and the problem was minimized, but still happens from time to time.
Through some research we found that the freeze-ups happen because the JVM does something called a "Full GC" or Full Garbage Collection, which supposedly frees no-longer-needed objects from memory, but in so doing, stops all other execution.
So I've been wondering, is there some sort of "magic formula" that we can tweak in the -xmx and -xms parameters so that code execution will ALWAYS be smooth? I've seen many people successfully use Java in many applications, and with the recent success of Android, I gather that there must not be a problem in Java, but rather, that we must be doing something wrong. So, what is it about java garbage collection? How do you guys deal with it, or has anyone even had problems with it? (Note: in the pure Java development I've done, I've never had problems like these)
Thanks for any advice on this.