Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a max size limit on the value of a JAVA_OPTS "-D" flag in Java?

I have a situation where the one of the JVM options, the "-D" flag is large, over 1000 characters. Is there a limit how large this value can be?

-Dhttp.nonProxyHosts=localhost|127.0.0.1|169.254.169.254|162.31.160.0/20|100.77.147.160/27|100.77.163.160/27|100.77.179.160/27|162.18.168.0/23|162.18.170.0/23|162.18.172.0/23|10.100.0.0/16|.internal|.foobr.com|.execute-api.us-west-2.amazonaws.com|.s3.us-west-2.amazonaws.com|.us-west-2.eks.amazonaws.com|.us-west-2.vpce.amazonaws.com|amazonlinux.us-west-2.amazonaws.com|api.sagemaker.us-west-2.amazonaws.com|cloudformation.us-west-2.amazonaws.com|cloudtrail.us-west-2.amazonaws.com|codebuild-fips.us-west-2.amazonaws.com|codebuild.us-west-2.amazonaws.com|config.us-west-2.amazonaws.com|dynamodb.us-west-2.amazonaws.com|ec2.us-west-2.amazonaws.com|ec2messages.us-west-2.amazonaws.com|elasticloadbalancing.us-west-2.amazonaws.com|events.us-west-2.amazonaws.com|kinesis.us-west-2.amazonaws.com|kms.us-west-2.amazonaws.com|logs.us-west-2.amazonaws.com|monitoring.us-west-2.amazonaws.com|runtime.sagemaker.us-west-2.amazonaws.com|secretsmanager.us-west-2.amazonaws.com|servicecatalog.us-west-2.amazonaws.com|sns.us-west-2.amazonaws.com|ssm.us-west-2.amazonaws.com|ssmmessages.us-west-2.amazonaws.com|sts.us-west-2.amazonaws.com
like image 603
Vijay Kumar Avatar asked Mar 17 '21 14:03

Vijay Kumar


People also ask

What is Java_opts?

JAVA_OPTS is an environment variable that you can set to pass custom settings to the Java Virtual Machine (JVM) that runs Liquibase.

What is Java_tool_options?

JAVA_TOOL_OPTIONS and _JAVA_OPTIONS are ways to specify JVM arguments as an environment variable instead of command line parameters. The are picked up by at least java and javac. They have this precedence: _JAVA_OPTIONS (overwrites the others) Command line parameters.

Where are JVM properties set?

The directory server provides a means of configuring the Java Virtual Machine (JVM) and Java options for each command-line utility and for the directory server itself. The Java configuration is provided in a properties file, located at instance-dir /OUD/config/java.

How do I set JVM options?

Update JVM Options Manually You can configure JVM options manually by editing the youtrack. jvmoptions file. This file is created automatically when you modify the default configuration. The location of the file depends on the distribution type of your YouTrack installation.


1 Answers

Yes and no. It's complicated. But mostly good news.

  • java does not care; the args are passed in as a string, though (and not as a stream from disk), which means there is a limit based on your memory. But, 1 GB's worth of text is... a lot of -D options. A few orders of magnitude more than you currently have.
  • The shell and the OS, however, certainly do. Windows, for example, cannot run commands that exceed 8191 characters in length. You're currently on ~1200 characters, so you can make your -D stuff about 7x longer than what you have right now, but then you're done, at least on windows. On posix it's dependent on OS and shell, but there are usually also limits. getconf ARG_MAX usually tells you what it is. On my desktop system it's currently 1048576, on a random linux shell i have access to, it's 2097152. That's a ton of room to grow for you.
  • You can avoid all problems by using the @ system. You can write java @foo.txt, which will cause the java executable to open foo.txt and use the contents of this file as arguments. So, put your giant -D switch in a file, and then use @allThatJazz.txt instead of -Dreallylongcommandlineoption. Now you can stop caring about OS imposed args limits.
  • Given that -D switches are available via System.getProperty, your limit is now heap related. We're talking hundreds of megabytes before it becomes unwieldy - 200,000,000 characters maybe.
like image 114
rzwitserloot Avatar answered Oct 07 '22 03:10

rzwitserloot