I am getting a out of memory error, when I tried to increase the jvm size, then the problem is not coming for one program and for other it is still facing the same problem(both programs are having same logic almost for different purpose) As I couldn't increase my jvm size according to my wish I tried to close all the objects that I am using in the program.what additional things I need to consider to overcome this problem?
I tried to close all the objects that I am using in the program
What does this mean? Assuming you mean you have dereferened them, this does not free them from memory. If you need stuff to be shifted out of memory more fequently, have a look a configuring you JVm's garbage collector.
Why can't you increase the amount of memory available? Have you tried performance testing your app. to find out how much it needs?
Take a look at following two issues: 1. database connections - always close result sets, connections if you use database data. 2. collections - always clear collections (lists, vectors, etc) when you don't need them anymore.
From my experience, that solves more than 80% of memory leak problems.
Outof memory only when it come when there is no memory for JVM.... Allocate the memory for your application..... And best thing is do the code profiling which will give you the better picture .... on your application memory leak... Due to that your JVM get squeez.....