hai friends,

Am developing java project with client server interaction,

am getting the Exception in thread "RMI TCP Connection(idle)"
java.lang.OutOfMemoryError: Java heap space

Exception, i doknow how to solve this ,please help me in this.

5 Years
Discussion Span
Last Post by JamesCherrill

Without the code or the full details of the Exception we can only guess.
But in general an OutOfMemoryError happens because (a) you have a ginormous amount of data in memory or (b) your code is stuck in a loop creating the same objects over and over again (more likely)


There are several JVM options that will increase the heap and stack size of the vm. Besides finding out what is eating all the memory, as James pointed out, you can look at garbage collection stats (java -verbose:gc, which will show, at least, how often the GC is running. You can increase your java heap size with -Xms and -Xmx, -XX:MaxPermSize. You can increase the java stack size with -Xss. Research these parameters before willy-nilly applying them, and go through your code to determine why you are running out of heap space. If you are using an IDE and running your program within the IDE, that's one reason you can quickly run out of memory.


Thanks for your kind reply friends,

its occur because stucks in a loop

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.