Reducing memory usage

From Bisq Wiki
Revision as of 23:01, 28 April 2021 by Plebeian9000 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Bisq is known to be a resource-hungry application, so some users may want to reduce memory usage.

Command-line fix

Reduce Bisq's memory usage by setting a ceiling of 4GB:

JAVA_TOOL_OPTIONS="-XX:MaxRAM=4g" /opt/bisq/bin/Bisq

/opt/bisq/bin/Bisq is the default application directory on Linux. If you run another operating system, you'll need to replace that path with the one for your OS.

You can adjust the scaling factor as you wish, of course, and add any runtime options for Bisq as well.

GUI fix

To have this setting apply automatically when running Bisq from a menu icon, you'll need to adjust the launcher files to run a script with the fix in it.

1. Create the script, say /opt/bisq/Bisq-runner.sh.

#!/bin/bash
JAVA_TOOL_OPTIONS="-XX:MaxRAM=4g" /opt/bisq/bin/Bisq

2. Make it executable.

chmod +x /opt/bisq/Bisq-runner.sh

3. Update the launcher (/opt/bisq/Bisq.desktop and/or /usr/share/applications/Bisq.desktop).

...
Exec=/opt/bisq/Bisq-runner.sh
...

Background

One of the settings Java virtual machines (JVMs) use to calibrate how much physical memory to reserve at startup is MaxRAM, and there is a good chance your JVM's default MaxRAM configuration is too large.

To check the default MaxRAM setting, run this java command:

java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version | grep MaxRAM

Look for the MaxRAM value (bytes) in the output. An example:

367: uint64_t MaxRAM = 137438953472 

This means the OpenJDK 11 JVM's MaxRAM setting is 128GB, much more RAM than the average desktop machine has.

Experiments have shown running Bisq with a 4GB MaxRAM setting reduces memory consumption by more than 50% (when starting a clean Bisq installation with an empty data directory). Setting MaxRAM to 2GB reduces resident memory usage even more, but setting it any lower (1536m) will result in an OutOfMemoryError and crash the app.

As of version 1.3.2, Bisq starts with a MaxRAM setting of 4GB. If you're still having issues, try setting the parameter yourself as described above.