Originally posted by West Richard:
Ernest to answer your question, its a simplification. Don't mind if i ask you but what makes you say it would not run out of memory?
Because the code you showed us uses a small, fixed amount of memory. There is nothing here with memory usage that will grow over time. This loop could copy the biggest file your OS could support, and it could do it with -Xmx8m -Xms8m on the command line, because it hardly uses any memory at all.
As a result, the only suggestions you're getting are to up your VM image size, and that's not helping you, right? If you showed us more code, maybe we'd spot where the memory was going, and we could help you fix the real problem.