This topic discusses JVM memory settings and system performance with VMware GemFire.
You configure JVM memory settings for the Java application by adding parameters to the java invocation. For the cache server, you add them to the command-line parameters for the gfsh
start server command.
JVM heap size—Your JVM may require more memory than is allocated by default. For example, you may need to increase heap size for an application that stores a lot of data. You can set a maximum size and an initial size, so if you know you will be using the maximum (or close to it) for the life of the member, you can speed memory allocation time by setting the initial size to the maximum. This sets both the maximum and initial memory sizes to 1024 megabytes for a Java application:
Properties can be passed to the cache server on the
gfsh command line:
gfsh>start server --name=server-name --J=-Xmx1024m --J=-Xms1024m
MaxDirectMemorySize—The JVM has a kind of memory called direct memory, which is distinct from normal JVM heap memory, that can run out. You can increase the direct buffer memory either by increasing the maximum heap size (see previous JVM Heap Size), which increases both the maximum heap and the maximum direct memory, or by only increasing the maximum direct memory using -XX:MaxDirectMemorySize. The following parameter added to the Java application startup increases the maximum direct memory size to 256 megabytes:
The same effect for the cache server:
gfsh>start server --name=server-name --J=-XX:MaxDirectMemorySize=256M
JVM stack size—Each thread in a Java application has its own stack. The stack is used to hold return addresses, arguments to functions and method calls, and so on. Since GemFire is a highly multi-threaded system, at any given point in time there are multiple thread pools and threads that are in use. The default stack size setting for a thread in Java is 1MB. Stack size has to be allocated in contiguous blocks and if the machine is being used actively and there are many threads running in the system (Task Manager shows the number of active threads), you may encounter an
OutOfMemory error: unable to create new native thread, even though your process has enough available heap. If this happens, consider reducing the stack size requirement for threads on the cache server. The following parameter added to the Java application startup limits the maximum size of the stack.
In particular, we recommend starting the cache servers with a stack size of 384k or 512k in such cases. For example:
gfsh>start server --name=server-name --J=-Xss384k gfsh>start server --name=server-name --J=-Xss512k
Off-heap memory size—For applications that use off-heap memory, specifies how much off-heap memory to allocate. Setting
off-heap-memory-size is prerequisite to enabling the off-heap capability for individual regions. For example:
gfsh>start server --name=server-name --off-heap-memory-size=200G
See Using Off-heap Memory for additional considerations regarding this parameter.
Lock memory—On Linux systems, you can prevent heap and off-heap memory from being paged out by setting the
lock-memory parameter to
true. For example:
gfsh>start server --name=server-name --off-heap-memory-size=200G --lock-memory=true
See Locking Memory for additional considerations regarding this parameter.