Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.OutOfMemoryError  RSS feed

 
Blikkies Marais
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a problem that the size of my application is using too much memory and I get a "java.lang.OutOfMemoryError
" error.
What I want to do is have a variable in a config file that sets the memory available to the JVM when my application starts up.
What is the java api that I can use in order to set the merory allocation pool? Please can you give an example of the java syntax?
Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't set it from Java; you have to set it on the JVM command line. For Sun's Java2 JVMs, the switch is -XmxNNm, where NN is the number of megabytes to use. So
java -Xmx128m MyClass
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!