There are more than 600 arguments that you can pass to JVM only for garbage collection and memory. It's way too many arguments for anyone to digest and comprehend. In this session, we will highlight seven essential JVM parameters that will improve the performance of your application.
3. Young: Newly created Objects
Old: New objects that survived
minor GC promoted here
Metaspace: Classes, Methods,
metadata
Others Description
Thread Stacks Each thread has a separate memory space. Controlled by -
Xss
Garbage
Collection
Thread, Memory to store GC info
Code Generation Converting bytecode to native code
Socket Buffers TCP Connections (Receive buffer ~37k, Send Buffer ~2.5k)
JNI JNI program also allocate memory
Does Java process memory utilization go beyond –Xmx?
Young old metaspace others
3
–XX:MaxMetaspaceSize
-Xmx
4. Large heap size with less JVM instances or Small heap size with large JVM instances?
-Xmx2g
Heap size arguments for Containers: -XX:MaxRAMPercentage
Benefits of setting initial & max heap size to same value
1. -Xmx
4
8. main( )
a( )
b( )
c( )
x=1
y*
z=2.11
public class SimpleExample {
public static void main(String args[]) {
a();
}
public static void a() {
int x = 1;
b();
}
public static void b() {
Car y = new Car();
c();
}
public static void c() {
float z = 2.11f;
}
}
Thread’s stack
Young old metaspace
car
-Xmx
-Xss
-
XX:MaxMetaspaceSiz
e
car
metada
How is Java program executed?
8
9. -Xss256k
Are Java threads – memory efficient?
JVM Version Thread stack size
Sparc 32-bit JVM 512k
Sparc 64-bit JVM 1024k
x86 Solaris/Linux 32-bit
JVM
320k
x86 Solaris/Linux 32-bit
JVM
1024k
Windows 32-bit JVM 320k
Windows 64-bit JVM 1024k
3. -Xss
9
21. 5. GC Logging
-XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:<file-path>
Till Java 8
-Xlog:gc*:file=<file-path>
From Java 9
yCrash, GCeasy, HP Jmeter, Garbage cat, IBM GC visualizer
Tools
Overhead added by Garbage Collection Logging
Almost Zero overhead
21
28. 28
Ram Lakshmanan ram@tier1app.com
@tier1app
This deck will be published in:
https://blog.ycrash.io
Learn to troubleshoot like a pro with my online training program
https://www.linkedin.com/company/ycrash