-
-
Notifications
You must be signed in to change notification settings - Fork 9
Added GC_FLAGS #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Added GC_FLAGS #31
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ module.exports = async function (deps) { | |
| log.info( | ||
| `Launching client with ${memoryConfig.source} memory settings: ${memoryConfig.args.join(' ')}` | ||
| ); | ||
| const commandArgs = [...memoryConfig.args, '-jar', jarPath]; | ||
| const commandArgs = [...memoryConfig.args, ...GC_FLAGS, '-jar', jarPath]; | ||
|
|
||
| // apply proxy args (done differently depending on client version) | ||
| const err = addProxyArgs(commandArgs, proxy); | ||
|
|
@@ -90,6 +90,7 @@ module.exports = async function (deps) { | |
| ); | ||
| const commandArgs = [ | ||
| ...memoryConfig.args, | ||
| ...GC_FLAGS, | ||
| '-jar', | ||
| jarPath, | ||
| '-clean-jagex-launcher' | ||
|
|
@@ -374,9 +375,55 @@ module.exports = async function (deps) { | |
| }; | ||
|
|
||
| const DEFAULT_XMS_VALUE = '512m'; | ||
| const DEFAULT_XMX_VALUE = '1g'; | ||
| const DEFAULT_XMX_VALUE = '600m'; // reduced from 1g — ZGC makes this safe to lower | ||
| const DEFAULT_CLIENT_RAM = DEFAULT_XMX_VALUE; | ||
|
Comment on lines
+378
to
379
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n libs/jar-executor.js | sed -n '375,385p'Repository: chsami/Microbot-Launcher Length of output: 458 🏁 Script executed: cat -n libs/jar-executor.js | sed -n '415,425p'Repository: chsami/Microbot-Launcher Length of output: 375 🏁 Script executed: cat -n libs/jar-executor.js | wc -lRepository: chsami/Microbot-Launcher Length of output: 71 🏁 Script executed: rg -n 'buildMemoryArgsFromRam' libs/jar-executor.js -A 20Repository: chsami/Microbot-Launcher Length of output: 2022 🏁 Script executed: rg -n 'function\|const.*=.*=>' libs/jar-executor.js | grep -i memoryRepository: chsami/Microbot-Launcher Length of output: 50 🏁 Script executed: rg -n 'GC_FLAGS' libs/jar-executor.js -B 3 -A 3Repository: chsami/Microbot-Launcher Length of output: 935 🏁 Script executed: rg -n 'args.*GC_FLAGS\|GC_FLAGS.*args\|concat\|spread' libs/jar-executor.js | head -20Repository: chsami/Microbot-Launcher Length of output: 50 Compute The hardcoded Additionally, This also applies to line 419. 🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * GC flags injected into every client launch. | ||
| * | ||
| * -XX:+UseZGC | ||
| * Switch from G1GC to ZGC. G1GC holds committed heap pages indefinitely | ||
| * even when they contain only dead objects. ZGC is designed to return | ||
| * unused pages to the OS, so Task Manager reflects actual usage rather | ||
| * than the worst-case watermark. | ||
| * | ||
| * -XX:SoftMaxHeapSize=500m | ||
| * ZGC targets staying under 500 MB before expanding toward Xmx. | ||
| * Acts as a soft pressure valve — heap grows to 600m only under real load. | ||
| * | ||
| * -XX:+ZUncommit | ||
| * Enables ZGC's page uncommit feature. Without this flag ZGC still uses | ||
| * less memory than G1GC but won't actively shrink the committed footprint. | ||
| * | ||
| * -XX:ZUncommitDelay=30 | ||
| * Pages idle for 30 seconds are returned to the OS. Lower values free | ||
| * memory faster; higher values reduce the cost of re-faulting pages back | ||
| * in after a brief spike. | ||
| * | ||
| * -XX:+UseStringDedup | ||
| * Deduplicates identical String objects across the heap. OSRS item names, | ||
| * NPC names, and chat messages frequently share the same content; this | ||
| * removes redundant copies automatically. | ||
| * | ||
| * -Xss512k | ||
| * Halves the per-thread stack from the default 1 MB. Microbot creates | ||
| * many script threads; 512 KB is ample for the call depths used. | ||
| * | ||
| * -XX:+IgnoreUnrecognizedVMOptions | ||
| * Prevents a crash if the bundled JRE is older than Java 15 and doesn't | ||
| * recognise ZGC flags — the client starts normally, just without the GC | ||
| * optimisations. | ||
| */ | ||
| const GC_FLAGS = [ | ||
| '-XX:+UseZGC', | ||
| '-XX:SoftMaxHeapSize=500m', | ||
| '-XX:+ZUncommit', | ||
| '-XX:ZUncommitDelay=30', | ||
| '-XX:+UseStringDedup', | ||
| '-Xss512k', | ||
| '-XX:+IgnoreUnrecognizedVMOptions', | ||
| ]; | ||
|
|
||
| function buildMemoryArgsFromRam(ramValue, log, contextLabel) { | ||
| if (!ramValue || typeof ramValue !== 'string') { | ||
| return null; | ||
|
|
@@ -431,4 +478,4 @@ function normalizeRamValue(value) { | |
| const mb = unit === 'g' ? amount * 1024 : amount; | ||
|
|
||
| return { normalized: `${amount}${unit}`, mb }; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# First, let's see the structure of the file and locate the key sections wc -l libs/jar-executor.jsRepository: chsami/Microbot-Launcher
Length of output: 92
🏁 Script executed:
Repository: chsami/Microbot-Launcher
Length of output: 2345
🏁 Script executed:
Repository: chsami/Microbot-Launcher
Length of output: 1628
🏁 Script executed:
Repository: chsami/Microbot-Launcher
Length of output: 2144
🏁 Script executed:
Repository: chsami/Microbot-Launcher
Length of output: 1296
🌐 Web query:
ZGC garbage collector Java 14 15 when introduced production ready💡 Result:
ZGC (Z Garbage Collector) was introduced experimentally in Java 11. It received significant improvements in Java 14, including Windows and macOS support, stability enhancements, and performance improvements. ZGC became production ready in Java 15 via JEP 377, which removed the experimental status and allowed enabling it simply with -XX:+UseZGC without unlocking experimental options.
Citations:
🌐 Web query:
-XX:IgnoreUnrecognizedVMOptions behavior prevent crash unrecognized flags Java💡 Result:
Yes, -XX:+IgnoreUnrecognizedVMOptions prevents the JVM from crashing (exiting with "Error: Could not create the Java Virtual Machine") when it encounters unrecognized -XX VM options. By default (disabled), the JVM prints "Unrecognized VM option" and fails to start. When enabled, it ignores such options (and some improperly specified ones), allowing the JVM to start successfully. This option was added to HotSpot to facilitate testing across VM variants (server/client, product/debug) where flags differ (JDK-6788376). Examples: - Without: java -XX:+UseConcMarkSweepGC -version (on JDK15+) → "Unrecognized VM option 'UseConcMarkSweepGC' Error: Could not create the Java Virtual Machine." - With: java -XX:+IgnoreUnrecognizedVMOptions -XX:+UseConcMarkSweepGC -version → Starts successfully, ignoring the flag. Note: It may also ignore some invalid value errors (e.g., out-of-range), printing a warning but continuing (behavior noted in JDK-8129855 for JDK9+). Use cautiously as it can mask configuration errors. It's commonly used in IDEs/build tools for compatibility across JDK versions.
Citations:
🌐 Web query:
ZGC experimental Java 14 JDK 15 UseZGC UnlockExperimentalVMOptions💡 Result:
In Java 14, ZGC is experimental and requires -XX:+UnlockExperimentalVMOptions -XX:+UseZGC to enable. In JDK 15, ZGC becomes production-ready via JEP 377, and -XX:+UnlockExperimentalVMOptions is no longer needed; use just -XX:+UseZGC.
Citations:
Add explicit Java version gating for ZGC flags, or remove the IgnoreUnrecognizedVMOptions fallback and require Java 15+.
ZGC is experimental in Java 14 (requires
-XX:+UnlockExperimentalVMOptions) and production-ready from Java 15+ onward. The code appends-XX:+UseZGCunconditionally at lines 52–53 and 91–97 without checking the Java version. While-XX:+IgnoreUnrecognizedVMOptionsprevents a JVM crash on Java 14, it causes silent degradation: the flag is ignored and the JVM falls back to G1GC. SinceDEFAULT_XMX_VALUEwas lowered to 600m assuming ZGC's behavior, Java 14 users would run with suboptimal settings. Either gate these flags onjava -versionoutput, or explicitly require Java 15+ and remove the IgnoreUnrecognizedVMOptions mitigation.🤖 Prompt for AI Agents