Hi I have a java application that is processing a number of records from a database. Now after processing about a 160 of these the java runs throws a “OutOfMemoryError: Java heap space”. Due to this I updated the entire function in order to only process 150 records at one go, which works fine when I simply call that function once, however the problem lies in that I have to process about a 10000 records, which means that I have to manually run the same function more then 60 times.
My question is, is there a way I can put this function in a loop and run it for various times without running into the problem. I cant understand why it runs into this problem since the function is self contained and does not make use of any of the data generated by the previous call to the function (as I said, I could manually run the function for 60 or so times and get the desired result).
Thanks in advance
Advertisement
Answer
Most likely you’re not closing your Statement
(s) and/or ResultSet
(s). These can consume a lot of resources while open. Be sure to close them when you’re through with them!