JVM Tuning
There are some recommended JVM settings for optimizing in ThingWorx performance that should be made. Fine tuning the JVM parameters beyond the ones that are listed below is workload specific and depends on the applications that are built with ThingWorx. For specific tuning based on your environment, contact PTC Support.
Mandatory Settings
Setting
Description
-server
Explicitly tells the JVM to run in server mode. This is true by default when using 64-bit JDK, but it is best practice to declare it.
-d64
Explicitly tells the JVM to run in 64-bit mode. The current JVM automatically detects this, but it is best practice to declare it.
XX:+UseG1GC
Tells the JVM to use the Garbage First Garbage Collector.
-Dfile.encoding=UTF-8
Tells the JVM to use UTF-8 as the default character set so that non-Western alphabets are displayed correctly.
-Djava.library.path
Specifies the path to the native library.
-Xms3072m (for a system with 4GB of memory)
Tells the JVM to allocate a minimum of 3072MB of memory to the Tomcat process. This should be set to 75% of the available system memory.
* 
The amount of memory needs to be tuned depending on the actual environment.
-Xmx3072m (for a system with 4GB of memory)
Tells the JVM to limit the maximum memory to the Tomcat process. This should be set to 75% of the available system memory.
* 
The reason that the min and max amounts of memory are made equal is to reduce JVM having to re-evaluate required memory and resizing the allocation at run time. While this is recommended for hosted and/or public-facing environments, for development and test environments, using –Xms512m would suffice. Also, verify that there is enough memory left to allow the operating system to function.
-Dlog4j2.formatMsgNoLookups=true
Optional Settings to Enable JMX Monitoring
If you suspect that there are memory issues, reference the following tools for more information on monitoring your system:. The setting listed will enable connecting those tools to the Tomcat instance used by ThingWorx to monitor the JVM characteristics.
Setting
Description
-Dcom.sun.management.jmxremote
Notifies the JVM that you plan to remote monitor it via JMX
-Dcom.sun.management.jmxremote.port=22222
The port the JVM should open up for monitoring.
-Dcom.sun.management.jmxremote.ssl=false
No SSL usage.
-Dcom.sun.management.jmxremote.authenticate=false
No authentication required.
-Djava.rmi.server.hostname=<host or IP>
The hostname or IP that the underlying RMI client connection will use.
Updating the –Xmx Parameter Value
When using the installer, all Java heap settings must be set in MB in the Service file by performing the following steps:
1. Stop the ThingWorx-Foundation.service from the default location /etc/systemd/system/ThingWorx-Foundation.service using the systemctl stop ThingWorx-Foundation.service command.
2. To confirm the service status is stopped, execute the command systemctl stop ThingWorx-Foundation.service command.
3. View the ThingWorx-Foundation.service file in the terminal using the vi command, and change the -Xmx parameter value. Make sure the file has root permissions. Refer to the screenshot below as an example.
4. Change the -Xmx parameter value from gb to mb and keep the unit as m. Make sure that it is greater than the initial heap value. Refer to the screenshot below as an example.
5. Execute the systemctl daemon-reload command.
6. Start the ThingWorx-Foundation service using the systemctl start ThingWorx-Foundation.service command.
7. Execute the upgrade installer again.
For more information, see PTC Support Article CS397788.
Was this helpful?