Child pages
  • Memory Management

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The two most important spaces of memory that a Java process uses are the Java Heap Space and the Java Perm Space. 

Java Heap Space

The Heap Space is the main space used by Java while operating. As such this space will use the most memory. The settings related to the Java Heap Space are the following:

  • Xmx - Maximum Heap Space value
  • Xms - Initial Heap Space Value

When the Maximum Heap Space size is too low for that is actually needed by the Java

...

For more information on Java Memory management, see http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf

Server Memory management

...

process, the following exception will be thrown: java.lang.OutOfMemoryError: Java heap space

...

Java Perm Space

...

The Perm Space is the space used by Java to store objects that are long lived. As such this space will ...... The setting related to the Java Perm Space is only the following.

  • XX:MaxPermSize - Maximum Perm Space value

When the Maximum Perm Space size is too low for that is actually needed by the Java process, the following exception will be thrown: java.lang.OutOfMemoryError: PermGen space

(warning)  The above mentioned settings are settings that can be applied when launching a Java process command-line or form a .bat/.sh script. Certain application might provide other ways to specify the same settings, for example the Service component that is part of the Servoy distribution. For more information on how to configure these settings withing Servoy, read the next paragraph.

Server Memory management

Determining the required memory

The memory consumption of a Servoy Application Server consists of the following parts:

...

  • Smart Client using the Servoy HTTP Tunnel:  assume 900kb for each Smart Client
  • Smart Client using another connection mode that the HTTP tunnel: assume 600kb for each Smart Client
  • Web Client, Headless Client & Batch processors: the required memory for each client depends on the size and design of the solution, but should be in the order of magnitude of a couple of Mb per Client. For more guidelines, see below.

Smart Client Memory usage vs. other Servoy Client

...

  • Small solution (1 - 50 forms), simple user interface: 5Mb
  • Medium size solution (50 51 - 500 forms), average complex user interface: 10Mb
  • Large solution (> 500 forms), complex user interface: 20Mb

Configuring the memory settings

The setting that requires tuning based on the determined required memory for the Servoy Application Server is the Maximum Heap Space setting (Xmx). By default the maximum heap size Maximum Heap Space is set to 256MB withing Servoy. This setting should be changed when:

  • The expected load is higher (see previous paragraph for determining the expected loadrequired memory)
  • The actual used memory is >= 70% of the specified maximum. The actually used memory can be found on the main page of the Admin page, under System Information: Heap memory: allocated=549184K, used=371473K, max=699072K
  • When there is plenty of free real memory available on the OS level. Java processes in general perform better when not having memory constraints. For example, when 2Gb free real memory is left, add the 2Gb to the maximum heap size. The Java process will only take what it needs.

Depending on how the Servoy Application Server is started, the Memory setting need to be applied in a different location.

...

Manual start: servoy_server.bat/.sh

...

When starting the Servoy Application Server manually through {serverInstall}\application_server\servoy_server.bat/.sh, the memory settings for the Application Server can be configured inside servoy_server.bat/.sh:

Code Block

java -Djava.awt.headless=true -Xmx256m -Xms64m -XX:MaxPermSize=128m .....
Auto start: wrapper.conf

When using the Service component to automatically launch the Servoy Application Server when the machine on which it is installed is booted, the memory settings for the Application Server can be configured inside {serverInstall}\application_server\service\wrapper.conf by altering the "wrapper.java.maxmemory" setting: 

Code Block
wrapper.java.additional.4=-XX:MaxPermSize=128m
# Initial Java Heap Size (in MB)
wrapper.java.initmemory=32
# Maximum Java Heap Size (in MB)
wrapper.java.maxmemory=256

For more information on configuring the Service component, see Running the server as a service

...

Manual start: servoy_server.bat/.sh

...

When starting the Servoy Application Server manually through {serverInstall}\application_server\servoy_server.bat/.sh, the memory settings for the Application Server can be configured inside servoy_server.bat/.sh, by altering the -Xmx value:

Code Block

java -Djava.awt.headless=true -Xmx256m -Xms64m -XX:MaxPermSize=128m .....
Starting in Servoy Cluster: start_servoy_clustered.bat/.sh

When the Servoy Application Server is part of a Servoy Cluster, the memory settings can be configured in {serverInstall}\application_server\terracotta\start_servoy_clustered.bat/.sh, by altering the -Xmx value:

Code Block
-Xmx256m -Xms64m -XX:MaxPermSize=128m

...

32bit Java Memory assignment limitation

...

(warning)  When the Servoy Application Server runs under a 32 bit JVM the maximum amount of memory that can be assigned to the Java process is 2Gb. This is a limitation of 32 bit. In order to be able to assign more memory, a 64 bit environment is required.

Smart Client Memory management

Initial Client Heap

Max. Client Heap

Virtual Machine Arguments

Java Virtual Machine (JVM) Tuning

Java version
Servoy supports both Java 5 and Java 6 (for the Application Server, the Smart Client and Servoy Developer). As Java 6 has numerous performance improvements, it is preferred over Java 5.

If the hardware in which Servoy is running is 64bit, make sure to also run a 64 bit Java Virtual Machine. When in doubt which version is used, check the Servoy Admin page, under "Servoy Server Home" > "Servoy Server Status" > "JVM Information":

  • 64 bit: java.vm.name=Java HotSpot(TM) 64-Bit Server VM
  • 32 bit: java.vm.name=Java HotSpot(TM) Client VM
Note

An 32 bit JVM will allow a max memory of 2 Gb in total, In order to run with larger heap sizes (over 2 Gb) you have to use 64 bit JVM on a 64 bit OS

Java Virtual Machine Server mode
Java has 2 distinct operating modes: client mode and server mode. When running in server mode, the startup of the Java process will take longer and initial execution of code will be slower, but after a while the application will perform faster. The server mode is best suited for the Servoy Application Server.

Whether or not a Java Virtual Machine supports client and/or server mode depends on the hardware, see http://download.oracle.com/javase/6/docs/technotes/guides/vm/server-class.html.

If the JVM supports servermode, it will automatically detect if the machine it is running on is a "capable" machine and automatically run in server or client mode depending. The definition of "capable" may differ from Java version to Java version. For Java 5/6 this means a 2CPU, 2Gb memory machine.

Checking whether or not a Servoy Application Server runs in client or server mode can be seen on the Servoy Admin page, under "Servoy Server Home" > "Servoy Server Status" > "JVM Information":

  • Server mode: java.vm.name=Java HotSpot(TM) 64-Bit Server VM
  • Client mode: java.vm.name=Java HotSpot(TM) Client VM

It is possible to enforce the Servoy Application Server to run in server mode (assuming the JVM is capable to operate in server mode), an extra startup argument can be added to the startup of the Servoy Application Server.

In servoy_server.sh/bat:

Code Block

java -server -Djava.awt.headless=true .....

When using the Service wrapper:

Code Block
# Java Additional Parameters
wrapper.java.additional.1=-Djava.awt.headless=true
wrapper.java.additional.2=-Duser.dir="C:\Servoy\application_server"
wrapper.java.additional.3=-XX:MaxPermSize=128m
wrapper.java.additional.4=-server

...

On Windows 32 bit environments, the Java Runtime Environment does not include support for server mode. In order to take advantage of server mode optimizations on 32 bit Windows systems, it is required to install Java Development Kit (JDK)

Memory

Processes in Java, like the Servoy Application Server, need to be told explicitly the maximum of memory they are allowed to use. This setting, the maximum heap size, is important to adjust to the load the Servoy Application Server is to handle.

The maximum heap size setting is located in {servoy_install}/application_server/servoy_server.sh/.bat, through the "Xmx" setting.

When the Application Server is started as a Service the setting can be found in {servoy_install}/application_server/service/wrapper.conf, by the name of "wrapper.java.maxmemory".

By default the maximum heap size is set to 256MB. This setting should be changed when:

...

  • Smart Client: assume a memory usage of about 600kb for each Smart Client. NOTE: When the Servoy HTTP Tunnel is used, assume 900kb per Client.
  • All other type of Clients (Web, Headless, Batch): the required memory for each client depends on the size and design of the solution, but should be in the order of magnitude of a couple of Mb per Client.

...

Note
titleSpecifying -Xmx and -Xms values

When specifying the -Xmx and -Xms values, the following needs to be taken into account:

  • The value can only be an integer value
  • The value needs to be places directly behind the parameter, no spaces or equal signs
  • The value needs to be post fixed with the unit: "m" or "M" for megabytes, "g" or "G" for gigabytes
  • When changing the -Xms options,  make sure that the -Xmx option has a higher value
  • Both values need to be lower than the available memory on the machine

...

32bit Java Memory assignment limitation

...

(warning)   An 32 bit JVM will allow a maximum memory assignment of 2Gb in total. In order to assign mor ethan 2Gb of memory, a 64 bit JVM on a 64 bit OS is required.

Monitoring the Memory usage

The actual memory usage of a Servoy Application Server can be observed on the Servoy Admin page. The "Servoy Server Status" overview on the "Servoy Server Home" page displays the allocated, used and maximum values for the Heap memory and all other spaces combined (non-Heap memory).

Smart Client Memory management

Similar to the Servoy Application Server, the Servoy Smart Client is also a Java application and as such the same memory management also applies to the Smart Client.

Through the Servoy Admin page, the following settings are exposed that related to the Smart Client's memory configuration:

Setting

What is does

Comment

servoy.initialClientHeap

Sets the Initial Heap Space size

 

servoy.maxClientHeap

Sets the Maximum Heap Space size

 

servoy.vmClientArgs

optional arguments that can be send to the Smart Client's JVM

Set to "-XX:SoftRefLRUPolicyMSPerMB=3600000" by default: this setting improves performance

(info)  Within the Servoy Smart Client, the actual memory usage can be monitored through the Help > About menu item.