Skip to main content

Resolve handle leaks in Worker

If a Worker process on Windows gets stuck, throwing the following exception: oshi.software.os.windows.WindowsOperatingSystem.updateProcessMapFromRegistry[:489] - Error 5 reading HKEY_PERFORMANCE_DATA from the registry, the application stops working, and a manual restart is required.

The issue is associated with the v3.9.1.1 OSHI library, with handles leaked even in idle mode without any Business Process processing. The library is used to regularly get data about Worker processes, such as memory consumption (once per second). Sometimes, handles are not cleaned properly during multiple iterations, which totals up to accumulated 10K handles per hour. If you restart Workers regularly, the issue does not occur.

However, you can slow the handle leakage by increasing the intervals between system information requests. For that, introduce the two new settings:

  • worker.execution.memory.heap.threshold.fixed.delay: time period, in milliseconds, between system information requests. The default value is 1,000.
  • worker.execution.memory.heap.threshold.initial.delay: time period, in milliseconds, before the start of the first system information request. The default value is 1,000.

To specify the settings as environment variables, complete the following steps:

  1. Go to RPA/bot-agent/conf/bot-agent-unit.yml for the server installation and RPA/worker/worker.bat for the VDI installation. Use the standard -D switch.

  2. Right after -Djvm.connector.path=../rpa-grid/dependency/jvm-connector.jar, insert the following lines:

    -Dworker.execution.memory.heap.threshold.fixed.delay=60000
    -Dworker.execution.memory.heap.threshold.initial.delay=120000

    Thus, the delay before you start getting system data is set to 2 (two) minutes, and the interval between requests—to 1 (one) minute.

Alternatively, you can choose one of the following methods to resolve the handle leakage issue:

  • Upgrade the OSHI library to the newest version, which resolves the issue entirely
  • Search for an alternative approach for getting system data