On Fri, Sep 24, 2010 at 3:38 PM, James Carroll <[email protected]> wrote: > Anyway, because the loops were running fast enough, I assume that > object creation got ahead of garbage collection, and I got: > Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
Without seeing your code it will be pretty much impossible to give any real specific responses. That said, there are a few simple things to keep in mind about heap usage. First, you can't "get ahead" of the garbage collector. As you use the heap, the collector will automatically preempt your program to reclaim unused space as needed. This will probably happen more often as you put additional pressure on the heap. Running the GC manually won't solve any of your problems. If you're seeing heap exhaustion then you're probably not releasing all references to the objects you're creating. Calling "new" in a loop isn't inherently bad, you just have to make sure you're not creating new references without releasing the old ones. Storing object references in collections and circular references are likely the biggest culprits for leaks. Nick -------------------- BYU Unix Users Group http://uug.byu.edu/ The opinions expressed in this message are the responsibility of their author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG. ___________________________________________________________________ List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list
