Skip to content

Instantly share code, notes, and snippets.

@iuriimattos
Last active May 22, 2025 19:30
Show Gist options
  • Save iuriimattos/509e7e16edc1a70015d6f75c91583a05 to your computer and use it in GitHub Desktop.
Save iuriimattos/509e7e16edc1a70015d6f75c91583a05 to your computer and use it in GitHub Desktop.
# custom IntelliJ IDEA VM options
-ea
-server
-Xms256m
-Xmx4096m
-XX:AutoBoxCacheMax=20000
-XX:MaxMetaspaceSize=512m
-XX:MetaspaceSize=128M
-XX:ReservedCodeCacheSize=512m
-XX:+AlwaysPreTouch
-XX:+UseG1GC
-XX:+UseStringDeduplication
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Dsun.awt.keepWorkingSetOnMinimize=true
-Dsun.io.useCanonCaches=false
-Dsun.java2d.uiScale.enabled=false
-Djava.net.preferIPv4Stack=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djsse.enablesSNIExtension=false
-Dfile.encoding=UTF-8
-Dhidpi=true
-Dide.ui.scale=0.8
-Duser.name=iuri.matos
@iuriimattos
Copy link
Author

iuriimattos commented Jun 11, 2022

@iuriimattos
Copy link
Author

@iuriimattos
Copy link
Author

iuriimattos commented May 22, 2025

2025 by Gemini

# custom IntelliJ IDEA VM options (expand/override 'bin\idea64.exe.vmoptions')
# Enable assertions - good for development, negligible performance impact for IDE
-ea

# Use the server VM for faster startup and better long-term performance
-server

# Initial and Maximum Heap Size
# With 32GB RAM, you can afford to give IDEA more memory.
# -Xms: Initial heap size. Setting it higher can reduce GC pauses during startup and initial indexing.
# -Xmx: Maximum heap size. Crucial for large projects and memory-intensive tasks.
# Consider values like 4GB to 8GB for Xmx, or even more if you work with extremely large projects.
# Let's start with a generous but not excessive allocation.
-Xms2048m
-Xmx8192m

# Max size for the cache of auto-boxed integer objects. Default is 128.
# Increasing this can be beneficial if you deal with a lot of boxed primitives.
-XX:AutoBoxCacheMax=20000

# Metaspace: Stores class metadata.
# -XX:MetaspaceSize: Initial size.
# -XX:MaxMetaspaceSize: Maximum size.
# The defaults you have are reasonable, but with 32GB RAM, we can give it a bit more breathing room
# to prevent frequent resizing, though for IDE performance itself, very large values aren't always necessary.
-XX:MetaspaceSize=256m
-XX:MaxMetaspaceSize=1024m

# Reserved Code Cache Size: Memory for JIT-compiled code.
# Default is often 240m or 480m. Increasing this can prevent the JIT compiler
# from being disabled if the cache fills up, which can impact performance.
# Given your RAM, a larger size is safe.
-XX:ReservedCodeCacheSize=1024m

# Pre-touch Java heap pages during JVM initialization.
# This can make startup a bit slower but ensures memory is committed,
# potentially improving runtime performance by avoiding page faults.
-XX:+AlwaysPreTouch

# Use the G1 Garbage Collector.
# Generally good for larger heaps and aims for more predictable pause times.
# This is often a good default for modern IDEs. [1, 5]
-XX:+UseG1GC

# Enables string deduplication, which can save memory if you have many duplicate strings.
-XX:+UseStringDeduplication

# Create a heap dump if an OutOfMemoryError occurs. Useful for diagnostics.
-XX:+HeapDumpOnOutOfMemoryError

# Provides more detailed stack traces for exceptions, which can be helpful for debugging IDE issues.
# The performance impact is generally minimal for IDE usage.
-XX:-OmitStackTraceInFastThrow

# UI and System Properties - Generally keep these as they are unless you have specific issues.
-Dsun.awt.keepWorkingSetOnMinimize=true
-Dsun.io.useCanonCaches=false
-Dsun.java2d.uiScale.enabled=false # Keep this if your UI scaling is handled by `ide.ui.scale`
-Djava.net.preferIPv4Stack=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djsse.enablesSNIExtension=false # Consider removing if you don't have specific SSL issues
-Dfile.encoding=UTF-8

# HiDPI and UI Scaling - These are specific to your display setup.
# If `ide.ui.scale=0.8` works for you, keep it.
-Dhidpi=true
-Dide.ui.scale=0.8

# Additional Performance Options to Consider (Add if needed):

# Can potentially improve performance by enabling more aggressive optimizations.
# However, it can also sometimes have unintended side effects. Test carefully.
# -XX:+AggressiveOpts

# Adjusts the compilation threshold. Lower values might compile code sooner.
# Default is 10000 for server VM. Experiment if you suspect JIT compilation is a bottleneck.
# -XX:CompileThreshold=5000

# For G1GC, you can try to set a target for maximum GC pause time in milliseconds.
# Don't set this too low, as it might force the GC to work harder and consume more CPU.
# -XX:MaxGCPauseMillis=200

# Sets the initiating heap occupancy percent for G1GC to start a marking cycle.
# Default is 45. Lowering it might start GC cycles earlier, potentially reducing fragmentation
# but could also increase GC frequency.
# -XX:InitiatingHeapOccupancyPercent=35

# For G1GC, sets the G1 region size. Must be a power of 2 between 1MB and 32MB.
# The JVM attempts to set this based on your heap size to achieve around 2048 regions.
# You might experiment if you have specific knowledge of your memory allocation patterns.
# -XX:G1HeapRegionSize=16m # Example, default is usually fine.

# If you experience high CPU usage due to JIT compilation, especially during typing,
# this option might help, but it can also slow down other IDE functions. [27]
# -XX:TieredStopAtLevel=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment