NoMachine Support

Your questions answered

Knowledge Base

Searching in: Articles & FAQs
Filter the search results
Applies to:
Last update:
Searching in: Articles & FAQs
ID: AR09L00809
Applies to: NX Server Products
Added on: 2014-09-19
Last update: 2019-04-16
Using Valgrind to detect possible memory leaks in the nxnode program

To debug the nxserver program with Valgrind, please read here: This feature is available since v. 6.1.

While investigating problems related to high memory usage into the session, the Support Team could request to run the Valgrind memory debugger in the user's environment to detect possible memory leaks. 

Instructions below assumes to run Valgrind on Linux.

The Valgrind debugger can be installed also on Mac OS.


To run Valgrind with NoMachine

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

2. Edit the node 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/nxnode.%p.out"

 NOTES for 3.

i) '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.

ii) 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" 

iii) 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.

iv) 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/nxnode.%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/nxnode.<pid>.out  file to the Support Team. 
<pid> is the pid of the nxnode.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 .