Date: Tue, 19 Mar 2024 08:35:12 +0000 (UTC) Message-ID: <1696062224.9897.1710837312820@911f0a1bad02> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9896_899547775.1710837312819" ------=_Part_9896_899547775.1710837312819 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Servoy is built using Java technology and as such the memory man= agement for Servoy is basically Java Memory management. This chapter descri= bes the basics of Java Memory management, which will be sufficient for all = but the most extensive and complex deployment scenario's.
The basics of Java Memory management is straight forward:
The two most important spaces of memory that a Java process uses are the= Java Heap Space and the Java Perm Space.
The Heap Space is the main space used by Java while operating. As such t= his space will use the most memory. The settings related to the Java Heap S= pace are the following:
When the Maximum Heap Space size is too low for that is actually needed = by the Java process, the following exception will be thrown: java.= lang.OutOfMemoryError: Java heap space
The Perm Space is the space used by Java to store loaded classes and oth= er static objects. The setting related to the Java Perm Space is only the f= ollowing.
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
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 p= rovide other ways to specify the same settings, for example the Service com= ponent that is part of the Servoy distribution. For more information on how= to configure these settings withing Servoy, read the next paragraph.
Java 8 changed the way it stored classes and is using now native memory = for that instead of a special java heap
these settings can be adjusted by using the following vm arguments:
-XX:MetaspaceSize=3D200M -XX:MaxMetaspaceSize=3D200M -XX:MinMetaspaceFre= eRatio=3D0 -XX:MaxMetaspaceFreeRatio=3D100
this sets it to use 200MB for that if you get a java.lang.OutOf= MemoryError: metaspace because a lot of plugins are used then you= need to update that value to something higher like 300/400.
Memory management for a Servoy Application Server revolves around managi= ng the values for the Java Heap Space and Java Perm Space.
The default values are:
Depending on how the Servoy Application Server is launched, the location= where these values can be managed differs:
{serverInstall}\app=
lication_server\service\wrapper.conf
{serverInstall}\application_ser=
ver\servoy_server.bat/.sh
{serverInstall}\app=
lication_server\terracotta/start_servoy_clustered.bat/.sh
The components that contribute to the Java Heap Space requirements for a= Servoy Application Server consists of the following parts:
The memory usage of a standard Servoy Application Server is limited to a= couple of Mb.
For database connections assume 2Mb per connection, so sum the Maximum A= ctive connections settings on each configured and enabled Database Server a= nd multiply that by 2Mb to determine the maximum memory consumption by all = database connections
The memory usage for the running Servoy Clients is more difficult to obt= ain, as it depends on the number of running Clients, the type of the r= unning Servoy Clients, the way the Servoy Solutions that are running are bu= ilt and the way the users use these Solutions. These variables together mak= e it difficult to provide hard numbers on how to configure the memory setti= ngs beforehand. Getting it right means monitoring and tuning.
As a starting point the following rule of thumb can be used to determine= the initial settings:
Smart Client Memory Usage vs. Other Servoy Client
The Smart Client runs on the client machine, not on the Servoy Applicati= on Server like the other Servoy Clients, like the Web Client, Headless Clie= nt or Batch Processor. The Smart Client is only registered with the Applica= tion Server and thus consumes far less memory on the Application Server com= pared to the other Servoy Clients. See Smart Client Memory management for more= information on configuring the Memory settings for Smart Clients specifica= lly.
Web Client, Headless Client & Batch Processors Memory Usage<= /strong>
The memory usage of Web Clients, Headless Clients and Batch Processors d= epends highly on the design of the solution. While Servoy optimizes many th= ings to keep the memory footprint as low as possible, it is logical that a = simple solution showing just one form at the time has a different memory fo= otprint than a solution that has a very complex UI, showing 20 Forms and/or= different sets of data at the same time.
The memory footprint is not linear with the number of Forms a = Solution contains, as Forms are instantiated on a need-to basis.
As there is no way to determine up front how much memory a Web/Headless/= Batch Processor Client will use, the only way to dimension the memory corre= ctly is by monitoring and tuning it.
For the initial dimensioning, use the following rules of thumb:
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 Space is set to 1028MB within Servoy. This set= ting should be changed when:
Depending on how the Servoy Application Server is started, the Memory se= tting need to be applied in a different location.
When using the Service component to automatically launch the Servoy Appl=
ication Server when the machine on which it is installed is booted, the mem=
ory settings for the Application Server can be configured inside {ser=
verInstall}\application_server\service\wrapper.conf
by altering=
the wrapper.java.maxmemory
setting:
wrapper.ja= va.additional.5=3D-XX:MetaspaceSize=3D200M wrapper.java.additional.6=3D-XX:MaxMetaspaceSize=3D200M wrapper.java.additional.7=3D-XX:MinMetaspaceFreeRatio=3D0 wrapper.java.additional.8=3D-XX:MaxMetaspaceFreeRatio=3D100=20 wrapper.java.additional.9=3D-XX:MaxPermSize=3D128m wrapper.java.additional.10=3D-XX:+UseG1GC # make sure that the hardcoded System.gc() or Runtime.gc() are ignored (rmi= does this) wrapper.java.additional.11=3D-XX:+DisableExplicitGC # Initial Java Heap Size (in MB), when G1GC is used just set the init memor= y to the max memory wrapper.java.initmemory=3D1280 =20 # Maximum Java Heap Size (in MB) wrapper.java.maxmemory=3D1280=20
For more information on configuring the Service component, see Running the Server As= a Service
When starting the Servoy Application Server manually, either through {serverInstall}\application_server\terracotta/start_servoy_c=
lustered.bat/.sh
, the memory settings for the Application Server can=
be configured inside the .bat/.sh, by altering the -Xmx valu=
e:
java ... -= Djava.awt.headless=3Dtrue -Xmx1280m -Xms64m -XX:MetaspaceSize=3D200M -XX:Ma= xMetaspaceSize=3D200M -XX:MinMetaspaceFreeRatio=3D0 -XX:MaxMetaspaceFreeRat= io=3D100 .....=20
Specifying -Xmx and -Xms values
<= /span>When specifying the -Xmx and -Xms values, the following needs to be take= n into account:
In a default Servoy Application Server installation, the Maximum Heap Sp= ace value (-Xmx) is set to 1280m. For servers that have limited memory, thi= s value could be too high, resulting in the following error when trying to = start the server:
Error occu= rred during initialization of VM Could not reserve enough space for object heap Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.=20
Either lower the -Xmx value or make sure that more memory is available f= or the Java process on the server, by closing other applications or adding = more physical memory to the server.
An = 32 bit JVM will allow a maximum memory assignment of 2Gb in total. In order= to assign more than 2Gb of memory, a 64 bit JVM on a 64 bit OS is required= .
By default the Java Heap Space size is set to 128Mb/200Mb, which is a su= fficient value for most deployments. A scenario in which this value needs i= ncreasing is when the Servoy Application Server is loaded up with a lot of = additional plugins, beans, LAF's and drivers.
For all three scenario's that the Servoy Application Server can be start= ed (as a service, manual stand-alone or manual clustered), the value for th= e Java Perm Space is controlled by the 'XX:MaxPermSize' setting in the abov= e mentioned configuration location for java 7 or for java 8:
-XX:MetaspaceSize=3D200M -XX:MaxMetaspaceSize=3D200M -XX:MinMetaspaceFre= eRatio=3D0 -XX:MaxMetaspaceFreeRatio=3D100
The actual memory usage of a Servoy Application Server can be observed o= n 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).
Or through Mon= itoring Servoy with JMX
For large heaps (more then 4G) that needs to handle quite a lot of Web o= r NGClients the vm needs some tuning to be able to handle this nicely.
Use the latest Java 8 and use the G1 Garbagabe collector for this and make sure that the initial he= ap and the maximum heap ist just set to the same value:
-server -Xms4G -Xmx4G -XX:+UseG1GC
-X=
X:MetaspaceSize=3D200M -XX:MaxMetaspaceSize=3D200M -XX:MinMetaspaceFreeRati=
o=3D0 -XX:MaxMetaspaceFreeRatio=3D100 -XX:+DisableExplicitGC
Where the 4G for the initial (Xms) and the max (Xmx) should be set to th= e maximum heap you want or can assign to the java vm.
Similar to the Servoy Application Server, the Servoy Smart Client is als= o 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 r= elated 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 Sm= art Client's JVM |
Set to '-XX:SoftRefLRUPolicyMSPerMB=3D3600000= ' by default: this setting improves performance |
With= in the Servoy Smart Client, the actual memory usage can be monitored throug= h the Help > About menu item.