On launch, we would load the piston index and runtime metadata files from local cache and then attempt to fetch updated ones (with usual online/offline/missing states).
`managedArgs` are managed by MultiMC and not directly visible to the user. They depend on the left hand side (variable by name) being set in order to be passed to Java. If there is no defined value of `minHeap`, `-Xms${value}m` is not passed to the JRE.
`startOnFirstThread` is then only specified on macOS, and replaces the current trait-based logic.
`hardArgs` are hardcoded, but do show up in the UI as 'default'/'ghost' and can be customized. Variables can be substituted into hardcoded args (like `heapRegionSize` for G1GC).
How the values for the variables are determined is internal to MultiMC and tuned to work well on all machines over time.
Existing Java settings in MultiMC have two layers -- global and per-instance.
The settings poorly accomodate resolving which Java to use, and/or determining the heap size and other java args dynamically.
For best user experience, the JRE settings should never have to be touched.
### Global settings
These affect every instance, unless overriden, and are present in `multimc.cfg`:
```
JavaArchitecture=64
JavaPath=java
JavaTimestamp=1635003862000
JavaVersion=17.0.1
JvmArgs=-verbose:gc
LastHostname=peterix
MaxMemAlloc=8192
MinMemAlloc=4096
PermGen=128
```
This allows only selecting one version of Java tied to one specificy JRE binary.
**Caching:**
When going between machines, or when the selected Java runtime disappears/changes, MultiMC asks you which Java to use again.
These variables stored in global settings are used to support that functionality.
-`JavaArchitecture` records the selected JRE's CPU architecture.
-`JavaTimestamp` records the last changed timestamp of the selected JRE's binary.
-`JavaVersion` records the selected JRE's version.
-`LastHostname` is used as a factor to pop up the JRE selection wizard.
**Actual options:**
-`JavaPath` is an absolute or relative path to the JRE binary. MultiMC can use a JRE stored in its data folder via the relative path, making it slightly more portable.
-`JvmArgs` are extra args added to the JRE args, by default empty.
-`MinMemAlloc` directly translates to minimum heap size (`-Xms${value}m` argument).
-`MinMemAlloc` directly translates to maximum heap size (`-Xmx${value}m` argument).
-`PermGen` directly translates to Java 7 and older 'Permanent Generation' size (`-Xmx${value}m` argument).
The default for PermGen in MultiMC is 128m.
```
if (permgen != 64)
{
args <<QString("-XX:PermSize=%1m").arg(permgen);
}
```
### Per-Instance settings
Per-instance settings mirror the global settings, but need to be toggled on with override settings.
With `OverrideLocation`, the instance uses its own Java runtime:
```
OverrideJavaLocation=true
JavaPath=/usr/lib/jvm/java-17-openjdk/bin/java
JavaArchitecture=64
JavaTimestamp=1635003862000
JavaVersion=17.0.1
```
With `OverrideMemory`, the instance will start with different memory amounts than specified in global settings:
```
OverrideMemory=true
MaxMemAlloc=8192
MinMemAlloc=4096
PermGen=128
```
With `OverrideJavaArgs`, the instance has its own extra runtime arguments (they are **not combined** with global):
```
OverrideJavaArgs=true
JvmArgs=-verbose:gc
```
There is also a legacy setting that overrides both location and args, but not memory.
This:
```
OverrideJava=true
JavaPath=/usr/lib/jvm/java-17-openjdk/bin/java
JavaArchitecture=64
JavaTimestamp=1635003862000
JavaVersion=17.0.1
JvmArgs=-verbose:gc
```
Is equivalent to this:
```
OverrideJavaArgs=true
OverrideJavaLocation=true
JavaPath=/usr/lib/jvm/java-17-openjdk/bin/java
JavaArchitecture=64
JavaTimestamp=1635003862000
JavaVersion=17.0.1
JvmArgs=-verbose:gc
```
The `OverrideJava` turns into `OverrideJavaArgs` and `OverrideJavaLocation` on instance settings save.