Java Memory Overview
1. Java Heap Size
Place to store objects created by your Java application
-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size
$ java -Xms512m -Xmx1024m JavaApp
related exception: java.lang.OutOfMemoryError: Java heap space.
2. Perm Gen Size
Place to store your loaded class definition and metadata.
-XX:PermSize<size> - Set initial PermGen Size.
-XX:MaxPermSize<size> - Set the maximum PermGen Size.
$ java -XX:PermSize=64m -XX:MaxPermSize=128m JavaApp
related exception: Java.Lang.OutOfMemoryError: PermGen.
3. Java Stack Size
Size of a Java thread. If a project has a lot of threads processing, try reduce this stack size to avoid running out of memory.
Place to store objects created by your Java application
-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size
$ java -Xms512m -Xmx1024m JavaApp
related exception: java.lang.OutOfMemoryError: Java heap space.
2. Perm Gen Size
Place to store your loaded class definition and metadata.
-XX:PermSize<size> - Set initial PermGen Size.
-XX:MaxPermSize<size> - Set the maximum PermGen Size.
$ java -XX:PermSize=64m -XX:MaxPermSize=128m JavaApp
related exception: Java.Lang.OutOfMemoryError: PermGen.
3. Java Stack Size
Size of a Java thread. If a project has a lot of threads processing, try reduce this stack size to avoid running out of memory.
$ java -Xss512k JavaApp
Check Your Java Heap Memory Size
$ java -XX:+PrintFlagsFinal -version | grep -iE 'heapsize|permsize|threadstacksize'
uintx AdaptivePermSizeWeight = 20 {product}
intx CompilerThreadStackSize = 0 {pd product}
uintx ErgoHeapSizeLimit = 0 {product}
uintx HeapSizePerGCThread = 87241520 {product}
uintx InitialHeapSize := 261254528 {product}
uintx LargePageHeapSizeThreshold = 134217728 {product}
uintx MaxHeapSize := 4181721088 {product}
uintx MaxPermSize = 174063616 {pd product}
uintx PermSize = 21757952 {pd product}
intx ThreadStackSize = 1024 {pd product}
intx VMThreadStackSize = 1024 {pd product}
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
Check Your Java Heap Memory Size
$ java -XX:+PrintFlagsFinal -version | grep -iE 'heapsize|permsize|threadstacksize'
uintx AdaptivePermSizeWeight = 20 {product}
intx CompilerThreadStackSize = 0 {pd product}
uintx ErgoHeapSizeLimit = 0 {product}
uintx HeapSizePerGCThread = 87241520 {product}
uintx InitialHeapSize := 261254528 {product}
uintx LargePageHeapSizeThreshold = 134217728 {product}
uintx MaxHeapSize := 4181721088 {product}
uintx MaxPermSize = 174063616 {pd product}
uintx PermSize = 21757952 {pd product}
intx ThreadStackSize = 1024 {pd product}
intx VMThreadStackSize = 1024 {pd product}
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
Comments
Post a Comment