Out of memory error
Iam running a java application through commandline on centOS operating system. This is multithreaded application. Also I am giving memory usage of 1024MB to this application. I am running 10 threads in this application. Program is very slow and threads are stopped automatically before complete execution of the thread. At last out of memory error occurred having java heap space problem. This is crawler application so this doesn't consume lot of memory. can anyone help me in solving this problem.
Ten threads is not the problem, unless centOS doesn't do threads well.
Do your threads, as they loop, have a Thread.sleep(), even for 1 millisecond? That can lead to sluggish behavior, if they never take a break.
Make sure you declare all your local fields outside of any loop; otherwise, you will continue create new fields on the stack, and that could get ahead of gc, or at least cause gc to run frequently, slowing things down.
Most likely, you are holding references to objects, so they cannot be gc'ed. Look for lists that are not cleared.
Most important, look for pairs of objects that refer to each other. gc cannot remove these objects.
Thanks Steve, for replying.
I am analyzing the application with visualVM monitoring tool. But while running both the application and monitoring tool, my application is terminated giving JVM error. Can you please tell me something about this problem.
Please post the exception(s).