about -xms option


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: about -xms option

  1. #1
    Join Date
    Feb 2006
    Posts
    24

    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

  2. #2
    Join Date
    Dec 2006
    Location
    Kerala,India
    Posts
    51
    -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)

  3. #3
    Join Date
    Feb 2006
    Posts
    24
    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?


    Quote Originally Posted by sudheerprem
    -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

  4. #4
    Join Date
    May 2005
    Location
    Ontario, Canada
    Posts
    173
    This is 100% against the Garbage collector that was introduced by Java to free unused memories.
    Am I right?
    Last edited by Kinda Electroni; 12-16-2006 at 09:21 AM.

  5. #5
    Join Date
    Dec 2006
    Location
    Kerala,India
    Posts
    51
    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)
    Last edited by sudheerprem; 12-16-2006 at 04:07 PM.

  6. #6
    Join Date
    Feb 2006
    Posts
    24
    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?


    Quote Originally Posted by Kinda Electroni
    This is 100% against the Garbage collector that was introduced by Java to free unused memories.
    Am I right?

    regards,
    George

  7. #7
    Join Date
    Feb 2006
    Posts
    24
    Thanks sudheerprem!


    Quote Originally Posted by 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.

    Quote Originally Posted by sudheerprem
    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

  8. #8
    Join Date
    Dec 2006
    Location
    Kerala,India
    Posts
    51
    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
    Last edited by sudheerprem; 12-17-2006 at 12:26 PM.

  9. #9
    Join Date
    May 2005
    Location
    Ontario, Canada
    Posts
    173
    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.

  10. #10
    Join Date
    Dec 2006
    Location
    Kerala,India
    Posts
    51
    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..!

  11. #11
    Join Date
    Feb 2006
    Posts
    24
    Thanks sudheerprem!


    Quote Originally Posted by 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

  12. #12
    Join Date
    Feb 2006
    Posts
    24
    Thanks Kinda!


    Quote Originally Posted by Kinda Electroni
    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

  13. #13
    Join Date
    Feb 2006
    Posts
    24
    Thanks Sudhi!


    Quote Originally Posted by sudheerprem
    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/...l#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

  14. #14
    Join Date
    Dec 2006
    Location
    Kerala,India
    Posts
    51
    what i meant with hard reference was an object that is strongly reachable. Sorry for the confusion.

  15. #15
    Join Date
    Feb 2006
    Posts
    24
    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. :-)

    Quote Originally Posted by sudheerprem
    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.


    regards,
    George

Similar Threads

  1. question on best programming option
    By James in forum .NET
    Replies: 2
    Last Post: 03-28-2002, 07:14 AM
  2. Re: Option Strict/Explicit
    By Mark Hurd in forum .NET
    Replies: 1
    Last Post: 08-05-2001, 12:04 PM
  3. Code for option box
    By navajo in forum ASP.NET
    Replies: 1
    Last Post: 10-27-2000, 06:25 AM
  4. Selecting option from a drop down box
    By patiala in forum ASP.NET
    Replies: 1
    Last Post: 10-24-2000, 05:51 PM
  5. Selecting option from a drop down box
    By navajo in forum ASP.NET
    Replies: 1
    Last Post: 10-20-2000, 10:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center