NoMachine Support

Your questions answered

Knowledge Base

Searching in: Articles & FAQs
Filter the search results
Applies to:
Last update:
Searching in: Articles & FAQs
ID: AR04P00976
Applies to: NoMachine Software
Added on: 2018-04-19
Last update: 2020-11-25
Using Valgrind to detect possible memory leaks in the nxserver program

To debug the nxnode program with Valgrind, please read here:

Since NoMachine v. 6.1, it's possible to use the Valgrind memory debugger also in the user's environment to detect possible memory leaks affecting the nxserver program.

Instructions below assumes to run Valgrind on Linux.

The Valgrind debugger can be installed also on Mac OS.


To run Valgrind with NoMachine nxserver.bin

1. Install the Valgrind tool if it's not already installed:

2. Edit the server configuration:


3. Uncomment and set the following keys:

EnableDebug 1

CommandDebug "/usr/bin/valgrind"

AcceptedDebuggerCommands "/usr/bin/valgrind,/usr/lib64/valgrind/memcheck-amd64-linux,/usr/lib/valgrind/massif-amd64-linux"

DebugOptions "--leak-check=full --show-reachable=yes --log-file=/tmp/nxserver.%p.out"

 NOTES for 3.

i) Comma-separated list in AcceptedDebuggerCommands should not contain spaces!

ii) 'CommandDebug' points to the Valgrind launch script.

   'AcceptedDebuggerCommands' points to the Valgrind binary(ies).

Be aware that paths and commands may vary on different Linux distributions. Values indicated above will work in most cases.

For exampe, depending on the operating system, the valgrind binary is named 'valgrind.bin' or 'valgrind'.

If the binary is 'valgrind.bin', set:

AcceptedDebuggerCommands "/usr/bin/valgrind.bin"
You can specify further binaries in a comma-separated list.

iii) Commands in 'AcceptedDebuggerCommands' can depend also on the architecture. For Linux 32 bit:

AcceptedDebuggerCommands "/usr/bin/valgrind,/usr/lib/valgrind/memcheck-x86-linux,/usr/lib/valgrind/massif-x86-linux"

iv) In case of problems to run Valgrind, check also the /usr/NX/var/log/nxerror.log file. For example a message like:
ERROR: Not an NX application: '/usr/lib64/valgrind/memcheck-amd64-linux'.
indicates that  the /usr/lib64/valgrind/memcheck-amd64-linux module should be adde to the 'AcceptedDebuggerCommands' key.

v) The Valgrind debugger can be installed also on Mac OS. Be sure to set appropriate values in the NoMachine 'CommandDebug' and 'AcceptedDebuggerCommands' configuration keys in order to fit your installation.

v) If it's requested by the Support Team to use the Massif tool heap profiler, change the DebugOptions key to have:

DebugOptions "--tool=massif --pages-as-heap=yes --massif-out-file=/tmp/nxserver.%p.massif.out"

4. Create a new session.

 NOTE for 4.

Note that CPU and memory usage will increase considerably when session is run with the debugger enabled.

5. Operate inside the session until the problem of high memory usage occurs.

6. Terminate the session that has reached a high memory usage.

    Note that disconnecting the session is not enough!

7. Send the  /tmp/nxserver.<pid>.out  file to the Support Team. 
<pid> is the pid of the nxserver.bin process which is leaking memory



To not impact all users:

1) set EnableDebug key to 1.

2) start a new session (session A).

3) Reset EnableDebug key to 0.

4) Leave session A running until you reproduce the problem.

In this way only session A is running under Valgrind, all the other sessions will be unaffected .