Solved

Make -Xmx a default java option?

Posted on 2006-06-25
13
3,565 Views
Last Modified: 2012-06-27
Hello,

I am running java on a virtual Linux server which limits the memory usage to just under 1GB. I've just installed the JDK 1.5, and when I run "java -version" I get:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

I've done some troubleshooting and have determined that Java is using the "-server" option as the default ("java -help" says so). I'm guessing that with the server version, the default memory usage is 1GB, because I can make Java work either by using "-client" or by specifying a smaller amount of memory (e.g. -Xmx512M). I can also reproduce the error above by using "-Xmx1024M"

Now for my question: is there an environment variable or property file that Java checks for default options? I'd like make the "java" command work by default by making java use "-Xmx512" by default.

Thanks in advance!
0
Comment
Question by:yoren
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 16979912
You could use an alias

alias j='java -Xmx512M'
0
 
LVL 7

Author Comment

by:yoren
ID: 16979990
The problem with an alias is that it doesn't work if you specify the full path, as some programs will do. Is there any way to configure java itself to use some options?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 90 total points
ID: 16980070
You could replace the java executable with a shell script pointing to the 'real' executable
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 16980230
Probelm with setting defaults is that if anything actually wants to set those params they are screwed. I think you would be better off having each applications startup script explicitly specify the startup option that they need.
0
 
LVL 7

Author Comment

by:yoren
ID: 16980260
Ideally, I'd like anything specified on the command line to override my "default" -Xmx64M. The script idea seems workable but is definitely a hack. Doesn't Java provide a default mechanism of its own?
0
 
LVL 92

Expert Comment

by:objects
ID: 16980302
> I am running java on a virtual Linux server which limits the memory usage to just under 1GB.

it shouldn't actuall y be doing that.
you may be better off rewsolving the actual problem, rather then implementing a hack
0
 
LVL 92

Expert Comment

by:objects
ID: 16980304
r they xen machines?
0
 
LVL 7

Author Comment

by:yoren
ID: 16980306
I take it back; the script idea won't work. It seems that javac and javadoc suffer from the same problem, but they don't have a "-Xmx" option I can use to fix them.
0
 
LVL 7

Author Comment

by:yoren
ID: 16980309
It's a VPS account with StartLogic, running Fedora Core 4. I'd be happy to run any commands you think could help identify the problem and report the result.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 35 total points
ID: 16980320
> but they don't have a "-Xmx" option I can use to fix them.

you can use the -J option

-J-Xmx64M  

I'd ask your ISP support about it, they have more than likely come across this problem before and may have a solution.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16981206
Out of interest, what is your JAVA_HOME environment variable set to? Does it point to the root directory of your JDK installation? And do you have %JAVA_HOME%\bin at the start of your PATH environment variable?
0
 
LVL 7

Author Comment

by:yoren
ID: 16983495
My JAVA_HOME variable is indeed set to the root directory of my JDK installation, and the path is set right.

Some more web searching reveals implies this is a common problem with virtual servers. I couldn't find a solution but found that it's because in server mode, Java picks 1/4 of the total memory.

CEHJ's script idea is the best solution I've found, along with the -J option for javac and all the other binaries.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16983524
:-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
web application structure 18 111
throw exception 21 66
Github api to fetch the number of collaborators in a git repo 1 27
Java array 10 55
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question