• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why my program throw the OutOfMemeory

 
Dingcheng lee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my program(is a monitor program).
after it run 6 hours ,it throw the Error of OutOfMemory.but when i see the system memory ,there are a larger memory not used. and how can I solve this problem and use the memory that not used.let it run a longer time?thanks!!!
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even though you have free RAM, the JVM may not have access to it. You can increase the JVM heap size by giving certain parameters.
For example,
java -ms64M -mx128M example.MyClass
starts the JVM with an initial heap size of 64 megabytes and gives it permission to grow up to 128 megabytes. The JVM will not exceed the mx-value.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, almost forgot.
The fact that your program slowly runs out of memory implies a "memory leak" in your code. I'd suggest double-checking all code that deals with collections of some sort and ensure that references are nullified as intended.
 
Dingcheng lee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear Lasse Koskela ,thanks a lot!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic