about -xms option
Hello everyone,
From the available documents from java.sun.com, I can not find rich information about this option, which is used to tune memory of JVM. Are there any samples/documents of this option, like the meaning/function/best practices of this option. Thanks.
regards,
George
[302 byte] By [
George3] at [2007-11-11 9:59:14]

# 1 Re: about -xms option
-X options are non-standard options, which can be changed without notice.
There will be a file called Xusage.txt in your JRE_HOME/bin/ directory, which tells about available options. -Xms is used for setting the minimum heap size and -Xmx is used for setting the maximum heap size.
eg: java -Xms200M -Xmx1024M <filename>
here the minimus heap size will set as 200MB and Maximum heap size will set as 1024MB (1GB)
# 2 Re: about -xms option
Thanks sudheerprem! I think the term for -Xms is not very accurate, because we often call it start memory. I think it should be called minimal memory to be more accurate, do you agree?
I have a further question, suppose I specify -Xms to be 100M, even if the JVM will not actually use that much memory, it will not release the unused memory. Is that correct?
-X options are non-standard options, which can be changed without notice.
There will be a file called Xusage.txt in your JRE_HOME/bin/ directory, which tells about available options. -Xms is used for setting the minimum heap size and -Xmx is used for setting the maximum heap size.
eg: java -Xms200M -Xmx1024M <filename>
here the minimus heap size will set as 200MB and Maximum heap size will set as 1024MB (1GB)
regards,
George
# 3 Re: about -xms option
This is 100% against the Garbage collector that was introduced by Java to free unused memories.
Am I right?
# 4 Re: about -xms option
If you give more space in -Xms option which is not available in the system, then while starting up, JVM throws an error saying that,"Could not reserve enough space for object heap". However i saw that even if we declare all available memory in -Xms option to run a small program, the process is not taking that much memory. So what i understand is, while JVM starting up, it will reserve the memory for further allocation, thus it can't be used for any other processes even if JVM is not actually using it.. I have done this test on jdk 1.6 on Windows and jdk 1.5 on Solaris,SLES9 and Windows
And I don't think that,Garbage Collector bothers about whether the memory is available or not..If an Object is not reachable through a Hard reference or WeekReference, GC can garbage collect the same (Including a SoftReference). (I made this assumption because, otherwise there is no point of having a consept called WeekReference which will garbage collect before throwing an OutofMemoryError..Correct me if i'm wrong)
# 5 Re: about -xms option
Hi Kinda, why do you say against GC? Do you mean using -Xms/x will be against some rules of best practices of Java programming?
But I think -Xms/x is good for performance tuning -- it will not be against anything. Any comments?
This is 100% against the Garbage collector that was introduced by Java to free unused memories.
Am I right?
regards,
George
# 6 Re: about -xms option
Thanks sudheerprem!
If you give more space in -Xms option which is not available in the system, then while starting up, JVM throws an error saying that,"Could not reserve enough space for object heap". However i saw that even if we declare all available memory in -Xms option to run a small program, the process is not taking that much memory. So what i understand is, while JVM starting up, it will reserve the memory for further allocation, thus it can't be used for any other processes even if JVM is not actually using it.. I have done this test on jdk 1.6 on Windows and jdk 1.5 on Solaris,SLES9 and Windows
Agree.
And I don't think that,Garbage Collector bothers about whether the memory is available or not..If an Object is not reachable through a Hard reference or WeekReference, GC can garbage collect the same (Including a SoftReference). (I made this assumption because, otherwise there is no point of having a consept called WeekReference which will garbage collect before throwing an OutofMemoryError..Correct me if i'm wrong)
I am interested in your above statements. What do you mean Hard reference and a Soft reference? Any formal documents/URLs dealing with them?
regards,
George
# 7 Re: about -xms option
I am interested in your above statements. What do you mean Hard reference and a Soft reference? Any formal documents/URLs dealing with them?
Hard Refernce is nothing but refering an instance directly in to a variable.
eg: String obj = new String("Test");
Here obj variable containes a hard reference of a String instance.
java.lang.ref package containes three types of references SoftReference,WeakReference and PhantomReference which support limited degree of interaction with Garbage Collector.
Please refer java API documentation for further information..
-Sudhi
# 8 Re: about -xms option
When I said:
This is 100% against the Garbage collector that was introduced by Java to free unused memories.
Am I right?
I was questioning the principle. Java is the one who introduced the principle of memory freedom.
To me it looked there is a conflict between the Garbage collector and the Xms/x.
Now, I think, it is clearer. As there are two different uses. Each one has its own area.
# 9 Re: about -xms option
I guess we can differenciate in the following way..
Xmx/s deals with the maximum/minimum memory reserved/required/used by the JVM for running the application as a whole and GC deals with the deallocation of memory used by the Objects inside that application.
It was a good discussion which helped us to think a lot on this consept.
Thanks George and Kinda..!
# 10 Re: about -xms option
Thanks sudheerprem!
I guess we can differenciate in the following way..
Xmx/s deals with the maximum/minimum memory reserved/required/used by the JVM for running the application as a whole and GC deals with the deallocation of memory used by the Objects inside that application.
Yes, I agree with your above points.
regards,
George
# 11 Re: about -xms option
Thanks Kinda!
When I said:
This is 100% against the Garbage collector that was introduced by Java to free unused memories.
Am I right?
I was questioning the principle. Java is the one who introduced the principle of memory freedom.
To me it looked there is a conflict between the Garbage collector and the Xms/x.
Now, I think, it is clearer. As there are two different uses. Each one has its own area.
I agree. Using -Xms/x is especially useful when we want to tune the performance by using more/less memory -- to control memory used by JVM manually to some degree.
regards,
George
# 12 Re: about -xms option
Thanks Sudhi!
Hard Refernce is nothing but refering an instance directly in to a variable.
eg: String obj = new String("Test");
Here obj variable containes a hard reference of a String instance.
java.lang.ref package containes three types of references SoftReference,WeakReference and PhantomReference which support limited degree of interaction with Garbage Collector.
Please refer java API documentation for further information..
-Sudhi
I have read some official resources. The references are categoried into three types, soft, weak and phantom. But you mentioned that there is some category called hard referece? Could you explain whether the following Java doc missed the hard reference please? Thanks again.
Quote from
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ref/package-summary.html#reachability
-------
A reference object encapsulates a reference to some other object so that the reference itself may be examined and manipulated like any other object. Three types of reference objects are provided, each weaker than the last: soft, weak, and phantom. Each type corresponds to a different level of reachability, as defined below. Soft references are for implementing memory-sensitive caches, weak references are for implementing canonicalizing mappings that do not prevent their keys (or values) from being reclaimed, and phantom references are for scheduling pre-mortem cleanup actions in a more flexible way than is possible with the Java finalization mechanism.
-------
regards,
George
# 13 Re: about -xms option
what i meant with hard reference was an object that is strongly reachable. Sorry for the confusion.
# 14 Re: about -xms option
Thanks sudheerprem! I have read some materials from java.sun.com, but the terms like hard reference, weak reference are described by each other -- for example, weak reference is defined by using hard reference, and I am totally confused when reading such information. :-)
what i meant with hard reference was an object that is strongly reachable. Sorry for the confusion.
I am wondering whether there are some documents which are more clear to understand -- I will can not understand what is hard reference and a strongly reachable object from your reply. Thanks. :D
regards,
George
# 15 Re: about -xms option
In JDK 1.3, there was a plan of having a java.lang.ref.HardReference. Since "Every normal object reference is a hard reference", same has not been introduced (still this is under discussion). Normal object reference is refered as Hard Reference. But there is no HardReference as such. Hope this clarifies..
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4416812
# 16 Re: about -xms option
Thanks sudheerprem!
In JDK 1.3, there was a plan of having a java.lang.ref.HardReference. Since "Every normal object reference is a hard reference", same has not been introduced (still this is under discussion). Normal object reference is refered as Hard Reference. But there is no HardReference as such. Hope this clarifies..
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4416812
I have read the bug description. But it is not very clear for beginners for the different types of references. Are there any basic documents/tutorials which deal with different types of references (and related samples)?
regards,
George
# 17 Re: about -xms option
probably this article will help you to understand more on this topic..
http://java.sun.com/developer/technicalArticles/ALT/RefObj/
# 18 Re: about -xms option
Very good article, thanks sudheerprem!
probably this article will help you to understand more on this topic..
http://java.sun.com/developer/technicalArticles/ALT/RefObj/
regards,
George