views:

1106

answers:

5

Hello

I am working on windows-2003 server(64-bit) with 8 GB ram. How can I increase the heap memory maximum. I am using -Xmx1500m command to increase the heap size with 1500mb. Can I increase the heap memory to 75% of physical memory(6GB Heap).

Thanks

A: 

Have you tried -Xmx6g ? Did this not work? What did you observe?

oxbow_lakes
Thanks for comment but this is not working
Sunil
Well - how do you know it isn't working? Does the JVM not start?
oxbow_lakes
A: 

Can I increase the heap memory to 75% of physical memory(6GB Heap).

Yes you can. In fact, you can increase to more than the amount of physical memory, if you want to.

Whether it is a good idea to do this depends on how much else is running on your system. In particular, if the "working set" of the applications and services that are currently running significantly exceeds the available physical memory, your system is liable to "thrash", spending a lot of time moving virtual memory pages to and from disk. The net effect is that the system gets horribly slow.

Stephen C
Thanks for your comment But How can I increase.Plz can you give command.
Sunil
Try -Xmx6000m. It ought to work if you are using a 64bit version of Java.
Stephen C
Sorry Boss it still not working
Sunil
Are you sure that you are running a 64bit version of Java? On a 64bit operating system?
Stephen C
+2  A: 

You can increase to 4GB on a 32 bit system. If you're on a 64 bit system you can go higher. No need to worry if you've chosen incorrectly, if you ask for 5g on a 32 bit system java will complain about an invalid value and quit.

As others have posted, use the cmd-line flags - e.g.

java -Xmx6g myprogram

You can get a full list (or a nearly full list, anyway) by typing java -X.

Steve B.
Thanks for comment
Sunil
It has been my experience that the actual heap size Java will accept using a 32b VM (on a 32b or 64b system -- the VM is the important part, here), is around 2G. Also, surprised asker did not first search and find: http://stackoverflow.com/questions/1596009/java-lang-outofmemoryerror-java-heap-spaceand:http://stackoverflow.com/questions/37335/how-to-deal-with-java-lang-outofmemoryerror-java-heap-space-error-64mb-heap-s
wsorenson
+1  A: 

On a 32-bit JVM, the largest heap size you can theoretically set is 4gb. To use a larger heap size, you need to use a 64-bit JVM. Try the following:

java -Xmx6144M -d64

The -d64 flag is important as this tells the JVM to run in 64-bit mode.

Kevin
Thank you boss but it is not working in my system there is some thing else I am missing
Sunil
Define "not working". Does it not start and give you an error? Does it start but use a different heap size?
Kevin
A: 

Blockquote## Heading ##

  • List item
jjj