> Perhaps the garbage collector thinks that its okay to leave around such a > small amount of garbage for more than a minute. > > Am I right?? It sounds weird that a garbage collector can cause a program to > crash!
Probably not. Garbage collectors will kick in after a certain threshold has been reached, and that threshold is usually set at the end of the last cycle. In other words, unless you have a real memory leak, the collector should keep the memory footprint stable. It's part of its job description. (The actual mechanism is far more complicated, but that's the bottom line). If you are using Sun's Java 6, you can monitor memory usage via JVisualVM, which comes as part of the JDK. JVisualVM also works well for Sun's Java 5 runtime. You'll have slightly reduced functionality and you need to supply an extra -D parameter to the Java 5 RE, but it does give you the pretty real-time graphs. That tool helped me a ton, a year or two ago, with little hassle for set-up, despite being tied to Java 5 at that time. (JVisualVM will even give you statistics about which data types take up most memory, show you all objects of a type, and will even do a breadth-first search for a stack frame that's keeping any given object alive. I'm not 100% sure how much of this is available for Java 5, but if Java 5 fails you can still try Java 6.) HTH Jo