Demystifying JVM Tuning: Practical Principles and Parameter Guide
The article outlines JVM tuning fundamentals, categorizing common issues, presenting six optimization principles, detailing key JVM parameters, and introducing the jps command‑line tool to help developers diagnose and improve Java application performance while maintaining stability.
Introduction
Although “JVM tuning” may sound sophisticated, understanding its underlying mechanisms makes it straightforward.
Scope of JVM Tuning
Resolve runtime problems, mainly memory overflow.
Optimize the runtime environment to improve speed and avoid stalling.
Plan and configure the JVM according to actual program requirements.
Ensure JVM stability.
Tuning Principles
Set JVM parameters to optimal values for the host machine.
Most Java applications do not require JVM-level optimization.
Reduce GC pauses caused by code (STW).
Minimize use of global variables, large objects, and object allocation frequency.
Address GC issues through code changes before tweaking JVM flags.
Prioritize architectural and code-level optimizations over JVM tuning.
Key JVM Parameter Settings
Typical stack and heap options include:
-Xss : thread stack size.
-Xms : initial heap size (default 1/64 of physical memory).
-Xmx : maximum heap size (default 1/4 of physical memory).
-Xmn : size of the young generation.
-XX:NewRatio : ratio of young to old generation (default 2, meaning young occupies 1/3 of total heap).
-XX:SurvivorRatio : proportion of a survivor space within Eden (default 8, i.e., 1/8 of Eden, roughly 1/10 of young generation).
-XX:MetaspaceSize : initial metaspace size.
-XX:MaxMetaspaceSize : maximum metaspace size (unlimited by default, JVM expands as needed).
Java Command‑Line Tool: jps
jps [options] [hostid]
# Options
jps -l : display the full package name of the main class or the full path of the jar file
jps -v : show JVM arguments of the process
jps -q : output only the process ID (PID)
jps -m : display the arguments passed to the main methodConclusion
Maintaining service stability first, then improving performance, is the ultimate goal of JVM tuning.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Coder Trainee
Experienced in Java and Python, we share and learn together. For submissions or collaborations, DM us.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
