William:
If this was my problem I would start by inserting System.out.println() statements giving current memory use in order to find out how far the program gets.
At the first look i thought: "Why do i have to put system.out, wont the stack trace give me the point till where it went!"
After a minute i got the answer myself, so thought i will post the same. (Both with an intent of confirmation and sharing)
Actually, OutOfMemory error will occur when JVM is not able to allocate new memory. The stack trace will tell the line where the memory allocation failed and it is not necessay that the line before that was the one where the last memory allocation happened. So, it is very difficult to determine "till where the program went" because the last memory allocation can be anywhere in the code and may be the same line which threw the OutOfMemoryError.
You may also try taking a heap dump using
jmap and then analyse it using
jhat to know what objects are taking the most of heap space.
By the way, there a lot of profiling tools available like JProbe, JProfiler that will help you if you want to do an advanced profiling.
[ May 19, 2008: Message edited by: Nitesh Kant ]