Announcement Announcement Module
Collapse
No announcement yet.
How to change memory and other JVM settings for STS Page Title Module
Move Remove Collapse
This is a sticky topic.
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to change memory and other JVM settings for STS

    STS runs on top of a JVM that is configured at startup with some default values that we think are suitable for many users. Nevertheless users may find other settings more useful for them, especially when using additional extensions for other languages like the Groovy or Scala, a larger heap can improve performance a lot, for example.

    The JVM that STS is running on is configured in the sts.ini file. You can find this in the same place as the STS executable (Mac users might need to dive into the STS.app bundle and there into Contents/MacOS). Open sts.ini and take a look at the default settings (among other settings which you should not touch):

    Code:
    -vmargs
    -Dosgi.requiredJavaVersion=1.5
    -Xmn128m
    -Xms256m
    -Xmx768m
    -Xss1m
    -XX:PermSize=128m
    -XX:MaxPermSize=384m
    Here you can change the maximum heap setting (-Xmx2048m for example) and all the other JVM options that your runtime offers.

    Note: Some operating systems, especially the 32bit ones, restrict the maximum memory setting for a single app to a specific amount, so STS might fail to start the JVM if your settings are not valid on your system. Backing up the sts.ini file before changing it is therefore recommended.

    I would also like to invite everybody to share their optimal settings here, so others can try out!

    Looking forward to reading about your experiences with different settings!

    Best regards,
    -Martin

  • #2
    For reference, here is my STS.ini (based on suggestion from http://www.beyondlinux.com/blog/?p=93). Note that I am running STS on a 8GB Mac.

    Code:
    -startup
    ../../../plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
    --launcher.library
    ../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.100.v20110502
    -product
    com.springsource.sts.ide
    --launcher.defaultAction
    openFile
    -vmargs
    -Dosgi.requiredJavaVersion=1.5
    -XstartOnFirstThread
    -Dorg.eclipse.swt.internal.carbon.smallFonts
    -server
    -Xmn128m
    -Xms1024m
    -Xmx2048m
    -Xss2m
    -XX:PermSize=128m
    -XX:MaxPermSize=512m
    -XX:+UseParallelGC

    Comment


    • #3
      Here is what I am using quite successfully on my 8GB OSX machine:

      Code:
      -vmargs
      -Dosgi.requiredJavaVersion=1.5
      -Xmn128m
      -Xss1m
      -XX:+AggressiveOpts
      -XX:+UseConcMarkSweepGC
      -XX:PermSize=64M
      -XX:MaxPermSize=712M
      -XX:+HeapDumpOnOutOfMemoryError
      -XX:CompileThreshold=200
      -XX:+UseCompressedOops
      -Xverify:none
      -XX:+UseBiasedLocking
      -XX:+UseFastAccessorMethods
      -Xms768m
      -Xmx1280m
      -XstartOnFirstThread
      -Dorg.eclipse.swt.internal.carbon.smallFonts
      Last edited by Martin Lippert; Mar 15th, 2013, 05:36 AM.

      Comment


      • #4
        Gentlemen,

        Any idea where I can find documentation to learn more about various parameters in STS.INI (e.g startup, launcher.library, launcher.defaultAction, etc)?

        Regards!

        Comment


        • #5
          Hey!

          The items above -vmargs are specific to the Eclipse-based launchers and should not be touched!!!
          More details on these items can be found here:
          http://help.eclipse.org/indigo/index...e-options.html

          HTH,
          Martin

          Comment


          • #6
            Thanks Martin! This definitely helps!!

            Regards!

            Comment


            • #7
              Hi all,

              I wrote an article on optimizing JVM settings here:

              http://philip.yurchuk.com/2011/08/15...tings-for-sts/

              I'm not a JVM expert, so I tried to give as much detail as possible and listed all my references. Hope it's of use to you.

              Thanks,
              Philip

              Comment


              • #8
                Originally posted by Martin Lippert View Post
                Here is what I am using quite successfully on my 8GB OSX machine:

                Code:
                -XX:+UseFastAccessorMethods

                I think this is default, so shouldn't affect anything.

                Comment


                • #9
                  Originally posted by Martin Lippert View Post
                  Some operating systems, especially the 32bit ones, restrict the maximum memory setting for a single app to a specific amount, so STS might fail to start the JVM if your settings are not valid on your system. Backing up the sts.ini file before changing it is therefore recommended.
                  well, this is true on my G5 with OS X 10.5.8 and jdk 1.5. However, I'm not sure it's simply a max as certain values for the max memory setting -Xmx does not take some lower numbers but does take some higher.

                  What I'd like to know is how to calculate which values are valid and which are not. Any ideas on this? I can't seem to find the pattern.

                  Currently this what I have but I'd like to give much more memory, like 2-3 gigs out of my 8:

                  Code:
                  -startup
                  ../../../plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
                  --launcher.library
                  ../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx_1.1.100.v20110502
                  -product
                  com.springsource.sts.ide
                  --launcher.defaultAction
                  openFile
                  launcher.XXMaxPermSize
                  384M
                  -vmargs
                  -Dosgi.requiredJavaVersion=1.5
                  -Xmn128m
                  -Xms768m
                  -Xmx1512m
                  -Xss2m
                  -XX:PermSize=128m
                  -XX:MaxPermSize=384m
                  -XX:CompileThreshold=100
                  -XstartOnFirstThread
                  -Dorg.eclipse.swt.internal.carbon.smallFonts
                  where settings in bold are what I believe non-default.
                  Last edited by MiB; Dec 4th, 2011, 07:18 AM.

                  Comment


                  • #10
                    Hey!

                    I don't know the exact details about how to calculate the exact maximum possible memory settings for a JVM, but according to this:
                    http://www.oracle.com/technetwork/ja...#gc_heap_32bit

                    it seems at least reasonable to get something between 1.4GB and 1.6GB when running a 32bit JVM.

                    HTH,
                    Martin

                    Comment


                    • #11
                      Originally posted by Martin Lippert View Post
                      Hey!
                      I don't know the exact details about how to calculate the exact maximum possible memory settings for a JVM, but according to this:
                      http://www.oracle.com/technetwork/ja...#gc_heap_32bit
                      it seems at least reasonable to get something between 1.4GB and 1.6GB when running a 32bit JVM.
                      HTH,
                      Martin
                      I also found an interesting discussion at stackoverflow: Maximum Java heap size of a 32-bit JVM on a 64-bit OS which makes some comparisons to 32bit on 64bit systems. It's just too bad Apple never made a 64bit JVM for the G5.

                      Anyway, it seems that on 32bit Mac OS X the maximum heap space is about 1590 MiB, making my 1516m as close as I can wish. However, for some reason certain lower values won't instantiate STS.

                      Is "1516m" about 1516 MiB or is it something else in this context?

                      I also checked the used resources of STS in Activity Monitor which states that about 588 MB is in use with about 2.5GB of virtual memory (150MB private virtual memory).

                      Anyone can suggest the best source for practical JVM knowledge?
                      Last edited by MiB; Dec 5th, 2011, 11:48 AM.

                      Comment


                      • #12
                        What about my 4G memory on win7 64bit os
                        Originally posted by Martin Lippert View Post
                        Here is what I am using quite successfully on my 8GB OSX machine:

                        Code:
                        -vmargs
                        -Dosgi.requiredJavaVersion=1.5
                        -Xmn128m
                        -Xss1m
                        -XX:+AggressiveOpts
                        -XX:+UseConcMarkSweepGC
                        -XX:PermSize=64M
                        -XX:MaxPermSize=712M
                        -XX:+HeapDumpOnOutOfMemoryError
                        -XX:CompileThreshold=200
                        -XX:+UseCompressedOops
                        -Xverify:none
                        -XX:+UseBiasedLocking
                        -XX:+UseFastAccessorMethods
                        -Xms768m 
                        -Xmx1280m
                        -XstartOnFirstThread
                        -Dorg.eclipse.swt.internal.carbon.smallFonts

                        Comment


                        • #13
                          Hi!

                          If you run a 64bit JDK and a 64bit STS, you can use an even higher max heap limit, if you want (-Xmx2048m, for example), but I would take care of not using too high settings for the max heap to avoid virtual memory swapping on your machine (slows down everything).

                          HTH,
                          Martin

                          Comment


                          • #14
                            thanks Martin,I user 64bit jdk and 64bit STS On my 64bit win7,I just set 256m ,but my laptop become very slowly ,so i want to get some optimization here

                            Comment


                            • #15
                              You can enable the heap monitor in STS to see what the current heap size is that STS is using (Preferences -> General), but I would recommend to use something around 1024m as -Xmx in your case.

                              HTH,
                              Martin

                              Comment

                              Working...
                              X