6/07/2006

6 Common Errors in Setting Java Heap Size

Two JVM options are often used to tune JVM heap size: -Xmx for maximum heap size, and -Xms for initial heap size. Here are some common mistakes I have seen when using them:

  • Missing m, M, g or G at the end (they are case insensitive). For example,
    java -Xmx128 BigApp
    java.lang.OutOfMemoryError: Java heap space
    The correct command should be: java -Xmx128m BigApp. To be precise, -Xmx128 is a valid setting for very small apps, like HelloWorld. But in real life, I guess you really mean -Xmx128m

  • Extra space in JVM options, or incorrectly use =. For example,
    java -Xmx 128m BigApp
    Invalid maximum heap size: -Xmx
    Could not create the Java virtual machine.

    java -Xmx=512m HelloWorld
    Invalid maximum heap size: -Xmx=512m
    Could not create the Java virtual machine.
    The correct command should be java -Xmx128m BigApp, with no whitespace nor =. -X options are different than -Dkey=value system properties, where = is used.

  • Only setting -Xms JVM option and its value is greater than the default maximum heap size, which is 64m. The default minimum heap size seems to be 0. For example,
    java -Xms128m BigApp
    Error occurred during initialization of VM
    Incompatible initial and maximum heap sizes specified
    The correct command should be java -Xms128m -Xmx128m BigApp. It's a good idea to set the minimum and maximum heap size to the same value. In any case, don't let the minimum heap size exceed the maximum heap size.

  • Heap size is larger than your computer's physical memory. For example,
    java -Xmx2g BigApp
    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Could not create the Java virtual machine.
    The fix is to make it lower than the physical memory: java -Xmx1g BigApp

  • Incorrectly use mb as the unit, where m or M should be used instead.
    java -Xms256mb -Xmx256mb BigApp
    Invalid initial heap size: -Xms256mb
    Could not create the Java virtual machine.
  • The heap size is larger than JVM thinks you would ever need. For example,
    java -Xmx256g BigApp
    Invalid maximum heap size: -Xmx256g
    The specified size exceeds the maximum representable size.
    Could not create the Java virtual machine.
    The fix is to lower it to a reasonable value: java -Xmx256m BigApp

  • The value is not expressed in whole number. For example,
    java -Xmx0.9g BigApp
    Invalid maximum heap size: -Xmx0.9g
    Could not create the Java virtual machine.
    The correct command should be java -Xmx928m BigApp
PS:

How to set java heap size in Tomcat?
Stop Tomcat server, set environment variable CATALINA_OPTS, and then restart Tomcat. Look at the file tomcat-install/bin/catalina.sh or catalina.bat for how this variable is used. For example,
set CATALINA_OPTS=-Xms512m -Xmx512m  (Windows, no "" around the value)
export CATALINA_OPTS="-Xms512m -Xmx512m" (ksh/bash, "" around the value)
setenv CATALINA_OPTS "-Xms512m -Xmx512m" (tcsh/csh, "" around the value)
In catalina.bat or catallina.sh, you may have noticed CATALINA_OPTS, JAVA_OPTS, or both can be used to specify Tomcat JVM options. What is the difference between CATALINA_OPTS and JAVA_OPTS? The name CATALINA_OPTS is specific for Tomcat servlet container, whereas JAVA_OPTS may be used by other java applications (e.g., JBoss). Since environment variables are shared by all applications, we don't want Tomcat to inadvertently pick up the JVM options intended for other apps. I prefer to use CATALINA_OPTS.

How to set java heap size in JBoss?
Stop JBoss server, edit $JBOSS_HOME/bin/run.conf, and then restart JBoss server. You can change the line with JAVA_OPTS to something like:
JAVA_OPTS="-server -Xms128m -Xmx128m"
How to set java heap size in Eclipse?
You have 2 options:
1. Edit eclipse-home/eclipse.ini to be something like the following and restart Eclipse.
-vmargs
-Xms64m
-Xmx256m
2. Or, you can just run eclipse command with additional options at the very end. Anything after -vmargs will be treated as JVM options and passed directly to the JVM. JVM options specified in the command line this way will always override those in eclipse.ini. For example,
eclipse -vmargs -Xms64m -Xmx256m
How to set java heap size in NetBeans?
Exit NetBeans, edit the file netbeans-install/etc/netbeans.conf. For example,
netbeans_default_options="-J-Xms512m -J-Xmx512m -J-XX:PermSize=32m -J-XX:MaxPermSize=128m -J-Xverify:none
How to set java heap size in Apache Ant?
Set environment variable ANT_OPTS. Look at the file $ANT_HOME/bin/ant or %ANT_HOME%\bin\ant.bat, for how this variable is used by Ant runtime.
set ANT_OPTS=-Xms512m -Xmx512m  (Windows)
export ANT_OPTS="-Xms512m -Xmx512m" (ksh/bash)
setenv ANT_OPTS "-Xms512m -Xmx512m" (tcsh/csh)
How to set java heap size in jEdit?
jEdit is a java application, and basically you need to set minimum/maximum heap size JVM options when you run java command. jEdit by default runs with a default maximum heap size 64m. When you work on large files, you are likely to get these errors:
java.lang.OutOfMemoryError: Java heap space
at java.lang.String.concat(String.java:2001)
at org.gjt.sp.jedit.buffer.UndoManager.contentInserted(UndoManager.java:160)
at org.gjt.sp.jedit.Buffer.insert(Buffer.java:1139)
at org.gjt.sp.jedit.textarea.JEditTextArea.setSelectedText(JEditTextArea.java:2052)
at org.gjt.sp.jedit.textarea.JEditTextArea.setSelectedText(JEditTextArea.java:2028)
at org.gjt.sp.jedit.Registers.paste(Registers.java:263)

How to fix it? If you click a desktop icon, or Start menu item to start jEdit: right-click the icon or menu item, view its property, and you can see its target is something like:
C:\jdk6\bin\javaw.exe -jar "C:\jedit\jedit.jar"
You can change that line to:
C:\jdk6\bin\javaw.exe -Xmx128m -Xms128m -jar "C:\jedit\jedit.jar"
If you run a script to start jEdit: just add these JVM options to the java line inside the script file:
java -Xmx128m -Xms128m -jar jedit.jar
If you start jEdit by running java command: just add these JVM options to your java command:
java -Xmx128m -Xms128m -jar jedit.jar
Note that when you run java with -jar option, anything after -jar jar-file will be treated as application arguments. So you should always put JVM options before -jar. Otherwise, you will get error:
C:\jedit>java -jar jedit.jar -Xmx128m
Unknown option: -Xmx128m
Usage: jedit [options] [files]
How to set java heap size in JavaEE SDK/J2EE SDK/Glassfish/Sun Java System Application Server?
Stop the application server, edit
$GLASSFISH_HOME/domains/domain1/config/domain.xml, search for XML element name java-config and jvm-options. For example,
<java-config suffix="...">
<jvm-options>-Xmx512m</jvm-options>
<jvm-options>-XX:NewRatio=2</jvm-options>
<jvm-options>-XX:MaxPermSize=128m</jvm-options>
...</java-config>
You can also change these settings in the web-based admin console, typically at http://localhost:4848/, or https://localhost:4848/. Go to Application Server near the top of the left panel, and then on the right panel, click JVM Settings | JVM Options, and you will see a list of existing JVM options. You can add new ones and modify existing ones there.

Yet another option is to use its Command Line Interface (CLI) tool command, such as:
./asadmin help create-jvm-options
./asadmin help delete-jvm-options
They may be a bit hard to use manually, but are well suited for automated scripts.

119 comments:

Anonymous said...

I got some, i got some! How about Xmx256m without minus, how about -Xmxtwohundredfiftysixmegas, how about -Xmxshowmesomelove?

Klaus Meffert said...

In opposition to the anonymous poster, I like your blog entry. Some days ago, I just ran over the problem coming up when you just use the Xms option. I'm sure many people had problems using these options. Maybe they should be reworked by Sun.

howto said...

Thanks for the comments. Admittedly, these errors are not hard to solve, if you look carefully enough. By putting them together, I hope to save people and myself some headaches in the future.

To the first anonymous commenter, I'm glad you got some and more :)

K.C. said...

Your Eclipse example should drop the -vmargs from the eclipse.ini file. When I add it, Eclipse refuses to start. You just need the -Xms128m...

R.P. Aditya said...

if you are on a 64-bit platform you can use a larger heap, but the Sun JVM requires you to specify -d64 to use the 64-bit data model

Anonymous said...

I have a finished application ready for distribution - xxx.jar

This app reads large amounts of data into a JTextArea. Very large amounts of data causes OutOfMemory exceptions.

I DO NOT want to run :
java -Xmx1024M -jar xxx.jar via a shortcut or batchfile, as this leaves a cmd window open.

Any way to spesify the Xmx/Xms values for the client JVMs via env variables? Or, is it possible to set the Xmx value programatically inside the app?

Thanks

admin said...

"Any way to spesify the Xmx/Xms values for the client JVMs via env variables? Or, is it possible to set the Xmx value programatically inside the app?"

No easy way around. You may want to consider using Java Webstart/JNLP.

DiablosDevil said...

Having read to put '-Xmx=256m' (which as you point out shouldn't have an '=') off the official Java forum, it's nice to see some correct information. Great help, thanks!

John said...

If you are running under cygwin you may need to change the run.sh or .conf file containing your options to unix format. If it is in DOS format there will be an extra linefeed character invisibly attached to the end of one of your options.

Anonymous said...

Thats was very useful.. got almost all information that I was looking for... Thanks a lot...

Regards
Surya

hownow said...

Very useful, except that I searched from Google and took the information from the search results (as I often do) and couldn't understand why "Xmx=256m" wouldn't work until I actually read the article :-)

Good work!

George said...

Something to be aware of:

Changing the Eclipse.ini vmargs changes the heap size used to run ECLIPSE

Changing the vmargs inside the "Run as.." menu in Eclipse changes the heap size used to run THE PROGRAM YOU ARE DEVELOPING

very important distinction to make

Manfred said...

Thanks George! (I just lost one hour figuring out how to change the heap for the PROGRAM and NOT for eclipse)

Just for completion:
Run As -> Open Run Dialog ->
-> (x)=Arguments -> VM Arguments

XaviF said...

Thanks you a lot, this information is what i'm looking for.

Very nice job!


Congrats.
Xavi.

Anonymous said...

For Windows, you can add a system or user based environment variable called _JAVA_OPTIONS and set the values you want, for example -Xmx1G. When you run a java app, the jvm will pick up the vm options from _JAVA_OPTIONS.

Haven't seen how to set VM options from within an app...

javahowto said...

Thanks for the above tip about using _JAVA_OPTIONS environment variable.

This works also on Linux and Solaris, as well as Windows.

C:\tmp>set _JAVA_OPTIONS="-Dname=javahowto"

C:\tmp>java A
Picked up _JAVA_OPTIONS: "-Dname=javahowto"

Russoue said...

Great post! Thanks!

Does the maximum heap size in eclipse.ini file affects the heap size of the programs it run or is it just to run itself?

javahowto said...

To Russoue,

No, eclipse.ini settings won't affect running apps inside eclipse.

Please see an earlier comment by George

Russoue said...

Oh, I missed it. Thanks for pointing that out to me.

Anonymous said...

I have 1 GB total space; out of which only 366 mb is free. In such case what argument should i use
-- currently i am using
-vmargs -Xmx1024m

It's frequently gives error for compiling whole prject (670 mb)
and exits from workbench
What should be the best arguments suitable for such situation

Dan said...

setting the _JAVA_OPTIONS environment variable doesn't seem to work for JNLP/Java Web Start applications. Anyone have any thoughts there?

thanks

Anonymous said...

Hi,
I try to setup some parameters for my applet, and I would like to know which of them is right:

*param name="vmargs" value="-Xms40m"**param name="vmargs" value="-Xmx1024m"*
or
*param name="Xms" value="256m"**param name="Xmx" value="1024m"*
or
*param name="Xms" value="256"**param name="Xmx" value="1024"*
or
*param name="-Xms" value="256m"**param name="-Xmx" value="1024m"*
or
*param name="-Xms" value="256"**param name="-Xmx" value="1024"*

Thank you for your information
Panchito

PS I had to replace the tag symbol by * symbol

javahowto said...

You can set it at users' end with Java Control Panel ($JAVA_HOME/jre/bin/ControlPanel) | Java Applet Runtime Setting, adding -Xmx256m to the Java Runtime Parameters column.

This change will apply to all applets running with this Java plugin.

Another option is applet developers specify memory settings for all clients of this applet. I suspect this is only available in Java SE 6 Update 10 Beta, and may not be available in official JDK 6 releases yet. The syntax is:

<APPLET ...>
<PARAM name="java_arguments" value="-Xmx128m"/>
/<APPLET>

See https://jdk6.dev.java.net/plugin2/#NEW_PARAMETERS

Anonymous said...

thankx a lot, I have some problems when I display big images in my applet, I will try to setup the heap max in order to your info to solve it.

Panchito

laptop battery said...
This comment has been removed by a blog administrator.
Felipe said...

Hi, thank you very much for this post, I find it very useful! I have problems of out of memory errors. I have a computer with 16 Gb of RAM memory. I use these commands to run the program: -Xmx3000m -Xms500m, but I get "The jvm could not be initialized", and if I reduce the maximum heap to 2600m I get and out of memory error. What can I do to solve this? thank you in advance!

javahowto said...

On typical 32 bit machines the maximum amount of usable RAM is about 4G, of which about half is reserved for OS. Unix OS reserves less amount memory and leaves more to applications. That may explains why it errors when you specify more than 2G for java VM process.

But in my experience, 1G is a LOT of memory for large java apps. Anything over that, the benefit of increasing memeory diminishes, and may be time to consider scale your app horizontally.

emjs said...

I have a problem with "out of memory" errors using Tomcat4.1. I have used your CATALINA_OPTS settings to see if this helps. On restart I notice that tomcat.exe is still only claiming 85MB of memory under taskmgr. With -xms set to 512m I would have thought this should be the value claimed by tomcat.exe. Should I be looking to see if my -xms value has taken effect in another way?

Anonymous said...

Is it any optimistic heap memory size there? or we can use any memory sizr?

hyoga said...

can you help me with this :
--------
Invalid initial heap size: -Xms4g
The specified size exceeds the maximum representable size.
Could not create the Java virtual machine.
--------
how is the max initial heap ?
fyi : im running solaris 10 with 32GB memory

thanks

dkmiberlin said...

we have a java app that runs our call center connection to the pbx. We would occasionally get an out of memory error on the cmd line box that shows up and would totally crash that app. We would then have to close it and restart it then it would run fine. Our command line bat was using the -Xmx512m switch. My thought was to increase this to -Xmx1g to give it a higher ceiling. when i did that i also added the Xms1g switch as well thinking that would in effect allocate that sytem memory to that app. when i did this it would only take 5-10 minutes to reach an out of memory error. Why would i get the error more frequently when i raised the Xmx? The java.exe process just grows and grows throughout the day. Any advice to make this more stable would be appreciated. We also wouldn't mind paying someone that knows Java and Jar files to take a look at our system and tell us what the problem is.my email is dkimberlin@bluefishtv.com

javahowto said...

If you haven't done so, try a static analysis tool such as BugFinder, or PMD to find any common memory leaks.

Next, try a java Profiler (OptimizeIt, JProbe, and even NetBeans comes with one) on a test machine. Pay attention to objects with abnormally high number of instances.

As your app is connected to pbx, jni may be a factor too.

uiyui said...
This comment has been removed by a blog administrator.
ELB said...

Thanks for this great article.
Starting my appli with -Xmx1500m leads to an OutOfMemory at runtime.
However, the appli works fine with -Xmx500m.
I can't see why this can happen (though there must be a good reason). Any idea ?

Anonymous said...

Hi all, I have a strange problem with CA-7 invoke a dummy java program through its CA-7 agent:

CA-7 can not run:
java -Xms2048M -Xmx2048M HelloWorld

CA-7 can not run:
java -Xms1536M -Xmx2048M HelloWorld

But it can run:
java -Xms2048M -Xmx1536M HelloWorld

(heap size errors).

We have no problem manually run it.

Our actual program run in production. Recently we had our datacenter migration and upgraded CA7.

I dumped the environment before it invoke the program. The environment variables are identical to those we run manually.

Any idea?

Thanks

Any ideas?
Thanks

Anonymous said...

Continue on my early post ...

We have 16GB total memory and 12GB available.

System setting has no limit on memory usage (at least we can run manually).

Thanks.

Anonymous said...

Thank you for all the useful information

Anonymous said...

George's Eclipse related tip, made me a star before my colleague today. 1.5 years later, my thanks.

Bhushan Bhangale said...

Informative content on setting heap size

Anonymous said...

Thanks a lot, George !

Anonymous said...

Good article, thank you.
I do have a Noob question...
If you have a sec... could you please explain what 'BigApp' does with regards to the parameters?.?
Is it a comment? ..or does it have a real effect?
Thanks in advance!

javahowto said...

BigApp is just the main class name, with default package. It can be replaced with any other name. It is not related to the memory settings.

PKS said...

Thanks a lot buddy... Your blog is very helpful in giving valuable info..... keep the good work going....

Sunil said...

I have Sun One Application server running on solaris 10. I am getting the same error and I got the recommendation to set the following settings.
I recommend that you change your Server's heap size from -Xms2g -Xmx2g to -Xms2048m -Xmx2048m and then restart the application server.
My question is, what is the difference in specifying 2048m versus 2g? are they not same?
can i increase it to upto 4g on 32 bit solaris machine? thanks

javahowto said...

I don't see any diff between -Xms2g -Xmx2g and -Xms2048m -Xmx2048m.

This is JVM option so the fact that you are running Sun Application Server shouldn't matter.

Sunil said...

Thanks JavaHowto. So I can change my heap size to 4g on solaris 32 bit. I have total of 8g available on my box. I read some posts stating that JVM can only use upto 2g. Does it make any difference? Thanks for your insights.

Sunil said...

Hello, I am running sunone app server on solaris. In my domain xml, heap size is allocated to 512m. For my node manged server(server1), heap size is allocated to 2g. Total RAM on this server is 8g. My app runs on node managed server1. My app is getting out of memory-heap error. How can I fix this? Is the above settings correct. thanks in advance

javahowto said...

Sunil, pls see http://weblogs.java.net/blog/sdo/archive/2007/12/a_glassfish_tun.html

and

http://docs.sun.com/app/docs/doc/819-3681

for more info on performance tuning with SunOne Application Server

Miguel said...

Very good post, you have save to me with it.

Thank you

rajesh said...

setting heap size in starttomcat - http://hiox.org/index.php?id=443

abhishek said...

Hi,
thanks for your info about .ini for eclipse,
it really worked for me.

Khandelwals said...

I have a huge data to put into Excel file, sometime rise up to 60k. it generate text data about 150MB. What would you do ? My user want to download that file. I know its ridiculous size for manual reading.

Please let me know if anyone has any solution.

Thanks
Ajay

Khandelwals said...

correction above...

at 60k ...it should be 60k Rows.

Thanks
Ajay

javahowto said...

Compress it, and let users download zip, gzip, b2, etc. Some have better compression rate than others.

javasrus said...

Javahowto,

thanks for your comment.
When compress, you start creating another compy of the same data in memory, increase in the use of memory, ...thats when it fails.

Thanks
Ajay

javasrus said...

Also, to zip it up, it has to be written on the disk, or unless you tell me you can zip the half cooked file, and actually that's when it fails.... I will share the code tomorrow.

Wheaties said...

ks

Purohit D said...

useful information for java developers for making software application on Java platform.

theRipper said...

For people questionning how to manage heap size parameters directly from the application : it's "too late" to set such settings on the jvm once the process is started. However the alternative is to use a launcher. On windows I'm using 'launch4J', that allows you to create an exe file out of a jar, specifying such jvm parameters (+ the application icon, version and copyright info, etc...). The exe will look for the jvm on windows then will execute the jar main class with your selected parameters.

Aschwin Versteegden said...

Sorry for asking this Noob question.
When I add Xms param I do this in the following section in the catalina.bat:

:doStart
shift
if not "%OS%" == "Windows_NT" goto noTitle
set _EXECJAVA=start "Tomcat" %_RUNJAVA%
set CATALINA_OPTS="-Xms512m -Xmx512m"

when I do this Tomcat won't start up it neither shows any logging at all.

before the section I edited said :

:doStart
shift
if not "%OS%" == "Windows_NT" goto noTitle
set _EXECJAVA=start "Tomcat" %_RUNJAVA%
set CATALINA_OPTS=

so the CATALINA_OPTS param was already set but with no value.
What is wrong here?

Aschwin Versteegden said...

Oke oke It wasn't me being a noob
Sorry here but your example said:
set CATALINA_OPTS="-Xms512m -Xmx512m"
In my case it should have been:
set CATALINA_OPTS=-Xms512m -Xmx512m
So that was very nice clearing a problem by just deleting quotes :-)
Too bad it took me over an hour or so to figure that out :-(

javahowto said...

Thanks for catching the problem with quotes. I've fixed the CATALINA_OPTS and ANT_OPTS.

So we should NOT quote the value when setting environment variables on Windows. But on Unix, we SHOULD quote the environment variable values when they contain white spaces.

Anonymous said...

In response to: I DO NOT want to run :
java -Xmx1024M -jar xxx.jar via a shortcut or batchfile, as this leaves a cmd window open.

you can run javaw -Xmx1024M -jar xxx.jar. this does not leave a cmd window open.This is the right way to prevent viewing cmd windows behind the app.

Purohit D said...

I appreciate the information. Java is one of the consistent player from the development industry which has been providing the wider scope for developers to come out with different solutions.

Purohit D said...

Sun Java is one of the most flexible platform for application development Sun Java development gives the way to develop complex applicaton development.

yipeng said...

I have tried setting -Xms128m -Xmx2048m but still get the following error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

While trying to parse a 700mb file inside eclipse. Anyone have any ideas for me?

Henry said...

Comments here are very good ones. It help resolve the errors I had while building spring framwork on my 2 G RAM laptop

Thanks everyone.

Edo

Anonymous said...

Thank you very much. this post has been very useful to me (and many others).

Green Parks said...

Hello.. Firstly I would like to send greetings to all readers. After this, I recognize the content so interesting about this article. For me personally I liked all the information. I would like to know of cases like this more often. In my personal experience I might mention a book called Green Parks Costa Rica in this book that I mentioned have very interesting topics, and also you have much to do with the main theme of this article.

caverta said...

Thank you very much. this post has been very useful to me (and many others).

Rossignol Axium SKI said...

thanks !! very helpful post!

semika said...

Good post. Thank you so much

Ankur said...

Thanks -- it's good to know that fractional memory sizes aren't allowed.

Ashok said...

Great Post... Solved my problem.

dugi's guide said...

Nice work on putting together a very interesting post. Fabulous ideas and very helpful information. Well thought out and well written.

Anonymous said...

turbulence training
nice post thanks for sharing....

Tim said...

I'm running a .jar through a Windows shortcut. Can I specify a maximum heap size in the shortcut, and if I can, what would the correct syntax be?

javahowto said...

@Tim: no. The best you can do is to write a .bat file to wrap the java command.

kamagra online said...

Hello,
Your blog contains very useful information. Thanks very much for sharing this amazing blog post, Keep updating your blog regularly... I'm looking forward to your new posts.

Thanks!

Joe said...

Awesome blog.. for jedit's right click, edit the HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with jEdit\Command key to include the Xmx too!

buy kamagra said...

Amazing information.Keep posting and sharing such kind of topic.

Dylan Rebert said...

You are a very smart person!

Vijay Pandey said...

i have set the parameter in eclipse.ini file but i still facing the same problem "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space"
Plz guide to me

gringo_starr said...

Thanks for good summary. I would add one more type of mistake that happend to me: in Windows Maven2 settings this does't work:

set MAVEN_OPTS="-Xms512M -Xmx512M -XX:MaxPermSize=512m"

JVM produces misleading error notification: "Invalid initial heap size: -Xms512M -Xmx512M -XX:MaxPermSize=512m"

The problem is with the quotations marks. One should instead use:
set MAVEN_OPTS=-Xms512M -Xmx512M -XX:MaxPermSize=512m

Javin @ eclipse remote debugging said...

Indeed most practical and insightful
tips.

Javin
5 tips on writing equals method in Java

Alpha0 said...

THere is one more common problem which people do is to put double quotes around the params on windows - which is wrong.
Just to confirm whether you could set the memory correctly, use jconsole and connect to your running application. You will be able to see if the memory limits are correctly set

Beth said...

Java is crazy! I can't stand using it, makes me think I need health supplements!

rajeev said...

Good post and the information shared are useful...

Thanks a lot...Keep doing these kind of work.

java arraylist tutorial said...

Nice article just to add Many people confused between Java heap and stack though both represent memory they are completely different to each other. Stack is where local variable are cretead or method stack trace are stored while heap is the memory where JVM stores objet.

SOK PHEARIN said...

Great job!!!
Thank you very MUCH!!!

Regards,
William

Abilene Roofing Company said...

Really great post, Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place.

alprazolam online said...

Hi, This is really nice information here.... very interesting too... Thanks for the share....

iulian said...

My file is
-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.1.R36x_v20100810
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms64m
-Xmx1024m

It said it can't start

Javin @ core java interview questions answers said...

good one mate, by the way here is mine way of solving java.lang.outofmemoryerror permgen space

extreme bondage sex said...

Very interesting! I have no expert, but I want have to know more and more, on your blog just interesting and useful information.

buy xanax online said...

Great articolo, è stato a great helpufl! Ho appena iniziato e conoscere meglio qui! Cheers, il buon lavoro keep you!

lesbian bondage videos said...

Great website, looks very clean and organized. Keep up the good work!

Rummy Online said...

Hi , i got this Article , i was searching some thing relevant to this, And i am feeling lucky, as its the perfect one for what i am looking for. I will share this link on face book.

cazare sulina said...

such a good language: java?

Cheap wedding dresses said...

I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.

Skater Stuff said...

i get this error



java -version
Picked up _JAVA_OPTIONS: .-Xms32m
Unrecognized option: .-Xms32m
Could not create the Java virtual machine.


what dose it mean?

dev said...

Hi Guys,
I am using Windows server 2008 64 bit , 12 GB RAM. Tomcat 7.0.22 64-bit. I want to increase heap size to 8 GB. I have created environment variable JAVA_OPTS and value part : -Xms512m -Xmx8192m after that i have also tried CATALINA_OPTS but it is also not reflecting the changes. In task manager java is using only upto 256 MB. Can any one please help me out to increase the heap memory in 64 bit machine.

juegos de futbol said...

This is a wonderful post. I enjoyed the information lot. I will bookmark this page.Thanks for sharing this important information.

Seminariruumid said...

I like to spend my free time by reading various internet resources. Today I came across your blog and I found it is as one of the best free resources available! Well done! Keep on this quality!

Seminariruumid said...

It took me time to analyze most of the feedback, but I honestly love the content. The idea proved to be very useful to me and I am sure to most of the bloggers out there! It feels good when you can not just be told, but you will also be entertained! I’m confident you had felt joy penning this post.

Waheed وحيد said...

In Netbeans to set your application heap size you need to go to right click on the project, select Properties then Run/VM-Options
and add your configuration opetions there.
The NB configuration file mentioned above is for NB it self.
Thanks for your article.

Anonymous said...

Excellent article! Just what I wanted and the way I wanted!! Kudos to you!

Kingitused said...

I'm really impressed with the content you provided. It's really helpful for me and I'm sure for others as well. Keep it up.

Anonymous said...

Good one... I have seen some good article at https://www.logicsmeet.com/forum/Core%20Java/21792-Error-occurred-during-initialization-of-vm-jboss.aspx

Thanks,

Anonymous said...

On aix, the variable IBM_JAVA_OPTIONS works, instead of _JAVA_OPTIONS.

Anonymous said...

thank you for this blog. helped me alot. i just have one question plz. from a clean boot into my centos web server. at the prompt i type 'java'. not even loading a jar app. just plain 'java' or 'java -version'. and i get the dreaded 'cant reserve enough space for object heap'. where is the global java/jvm settings file so that i can adjust the heap size as per your guidelines above?

javahowto said...

Can you try "which java", just to see the exact executable. Also check if the executed java executable is compatible with your OS and hardware, 32 bit or 64 bit, etc.

adeel said...

Thanks for the no-double-quotes for windows tip on max heap size for tomcat

jerseys cheap said...

Thanks for the comments. Admittedly, these errors are not hard to solve, if you look carefully enough. By putting them together, I hope to save people and myself some headaches in the future.

Pierre-Hugues Charbonneau said...

Very complete article on Java heap size. Your readers may also be interested in more tips on how to tune the Java heap; especially for a Java EE environment.

Thanks.
P-H

Anonymous said...

I was able to set the java java heap space on windows via the java control panel runtime parameters, but these get wiped out if you restart the machine.

-Xms1024m -Xmx1024m

How do you make these runtime parameters permanent?

Anonymous said...

Nice, this is very helpful. If you are running jar you should try this one "java -jar -Xms512m C:\locationOfYourJar" with out the double quotes

Sunsoft Shanmugam said...

Great Works,
valuable information about java setup
Thank you
php development company

saransh khanna said...

Thanks for the great information..




Php Development Company