When Servoy is using significantly more memory that expected, the memory usage can be analysed on the Java level.

While setting up the tools to make inspection of the memory used by Servoy is relatively straight forward, the actual analysis required detailed understanding of both Java and up to a point the Servoy codebase. As such, doing the actual analyses is not for everyone, but the tools described in this tutorial allow for making a dump of the entire memory usage to file, which can then be send to anyone with the skills to do the analysis, for example Servoy Support.

Setting up the tooling

Part of the Java Development Kit (JDK) is a tool called VisualVM which shows all kinds of info about the Java Virtual Machine (JVM) and allows to dump the memory.

As VisualVM is part of the JDK, it is not available in the Java Runtime Edition (JRE). If JDK is not installed, it must be installed first.

Make sure to have a JDK and thus VisualVM installed for the same architecture (32 vs. 64 bit) as the Java process used that is to be inspected. When using a 32-bit VisualVM to inspect a 64-bit Java process, not all options of VisualVM will be available, like the option to make a memory dump 

Running VisualVM

VisualVm can be found inside the JDK installation folder: {JDK_INSTALL}\bin\jvisualvm.exe/sh

When launched (on Windows) the GUI looks like:

Note that services can't be inspected, so it the process that needs to be inspected is a Servoy Application Server running as a service, the Java process of the Servoy Application Server cannot be inspected. In order to inspect that Servoy Application Server, the service must be stopped and then the Servoy Application Server must be started manually.

Making a dump of the memory

The steps to make a dump of the memory to file, for further inspection are the following:

  1. Select the process to inspect in the Applications pane
  2. Select the "Monitor" tab of the process to inspect
  3. Press the "Heap Dump" button

As the heapdump can be quite large, consider zipping it before sending it to a 3rd party or attaching it to a case in the Servoy Support system

Perhaps even use (drop)box to share a link to the zipped dump in the support case