How JVM parameters are configured under different scenarios

Source: Internet
Author: User
Tags ini
1. Set the JVM parameters through Eclipse.ini, which will take effect after Eclipse is started, as follows:
-vmargs
-dosgi.requiredjavaversion=1.5
-xms512m
-xmx512m
-xmn128m
-xx:permsize=64m
-xx:maxpermsize=256m
-xx:+disableexplicitgc

Note: It is important to note that, often, after we have set the JVM parameters through Eclipse.ini, Eclipse cannot start and report a similar error


2. Configure the JVM parameters for a single test case or test class, which takes effect when running the use case, such as:
Right-click on the test case you want to run, run as = + Run configurations = Find the JUnit column in the Open run configurations, locate your test case under the JUnit column, and if not, double-click the JUnit = "Open arguments Tab, enter the JVM parameter to be set in the VM arguments column =" click Run.


3. Configure the JVM parameters for one of the jdk/jre loaded by eclipse, which takes effect when the test case is run.
The difference from 2 is that the parameter configuration is global and does not need to be configured separately for each test case when running the use case.
Select Window=>preferences=>java=>installed jres=> in Eclipse to select the installed JDK or JRE and edit = "in the default VM Enter the JVM parameters to set in arguments = "Click Finish to complete the setup."


This can be set by the environment variable java_opts, similar to the maven_opts and Antx_opts mentioned later. Not in detail here. how the JVM is configured for MAVEN projects

1.  Configuring JVM parameters for Maven run
This is a rare requirement, typically using the default JVM configuration. If required, you can set environment variables to meet your needs, such as:
         Add environment variables under Windows Maven_ The value of opts is-xms1024m-xmx1024m-xss1m
         Under Linux, you can modify the. Profile or. bash_profile file and make the following settings:
                        export maven_opts= "-xms1024m-xmx1024m- Xss1m "
                         (Note: You need to use double or single quotes here)

2. When configuring JVM parameters for new child processes that Maven fork (such as when running test cases from the command line MVN tests)
Maven runs test cases, By calling Maven's Surefire plugin and fork a subprocess to execute the use case, you can add the JVM parameters directly in the configuration of the Surefire plugin, as follows:
<plugin>
         <groupid>org.apache.maven.plugins</groupid>
         <artifactid>maven-surefire-plugin</artifactid>
         <configuration>
             <forkmode>pertest</forkmode>
             <argline>-xms1024m-xmx1024m-xss1m </argline>
         </configuration>
</plugin>
Note: maven_ The JVM parameters set by the OPTs method are not valid for the sub-processes that are forked out, so for running test cases with MVN test, you need to configure them separately. how the JVM is configured for ANTX projects

1. Configure JVM parameters for Antx run
here is similar to configuring JVM parameters for Maven run, you can set the environment variable antx_opts to meet the requirements, such as:
     Add environment variables under Windows antx_opts value for-xms1024m-xmx1024m-xss1m
    Linux can be modified. Profile or. bash_ Profile file and make the following settings:
                      export antx_opts= "-xms1024m-xmx1024m-xss1m"
                      ( Note: You need to use double or single quotes here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.