views:

85

answers:

4

hello, I have to create a RMI program,when i run this program it will run only few minutes then show "java.lang.outofmemoryError: java heap space" problem. I have to use Window 7 with 1.5 GB RAM and JDK1.6

Thanks,

A: 

You may simply need to increase your maximum heap size using the -Xmx option.

You could read this tuning guide

djna
+1  A: 

Smells memory leak. Although Java does garbage collection, you still need to make sure you don't hold onto (strong reference) to objects that you no longer need. For example, if you do not unregister event handlers (and event handler boilerplate code holds strong reference to the handlers), those handlers will never be collected and thus memory leak.

Without knowing more of your program, we can just guess here.

Xian Xu
A: 

Memory leak. Use jvisualvm in the jdk to find out why.

Thorbjørn Ravn Andersen
A: 

This can be a one of several things.

  • You may have a memory leak. In a garbage collected environment this means you are holding on to memory you no longer need. Using a profiler (Yourkit or whatever) to do memory profiling will help to determine what it is you are holding on to, and how.
  • Depending on your jvm version, the default heap allocation may not be all that much. It is possible, though not likely for an rmi application, that you are legitimitely running out of memory. Use the -Xms switch to increase the initial heap size, and -Xmx to limit the heap's maximum size. e.g.
    java -Xms128m -Xmx512m ...
jvdneste