NoMachine Support

Your questions answered

Knowledge Base

Searching in: Articles & FAQs
Filter the search results
Applies to:
Last update:
Searching in: Articles & FAQs
ID: AR06R01092
Applies to: NoMachine Server
Added on: 2020-06-25
Last update: 2020-06-26
How to solve abnormal memory usage in nxnode.bin process

An abnormal memory usage has been detected in NoMachine node during multiple creation and reconnection to the virtual desktops.

Such abnormal allocations are due to 'malloc arenas', which are a glibc optimization feature. Arenas' default size is 64 MB and their default maximum number is 8 * number of CPU cores.

Example of memory stack:
    100.00% (1,585,655,808B) (page allocation syscalls) mmap/mremap/brk, --alloc-fns, etc.
    ->88.68% (1,406,087,168B) 0x577F559: mmap (syscall-template.S:81)
    | ->46.55% (738,197,504B) 0x570846F: new_heap (arena.c:561)
    | | ->46.55% (738,197,504B) 0x5708F17: arena_get2.isra.3 (arena.c:741)
    | |   ->46.55% (738,197,504B) 0x570D3A5: malloc (malloc.c:2887)
    | |     ->33.86% (536,870,912B) 0x7DD7B17: Local::getData() (in /usr/NX/lib/libnx.so)
    | |     | ->29.63% (469,762,048B) 0x7DD30B9: Monitor::loop(void*) (in /usr/NX/lib/libnx.so)
    | |     | | ->29.63% (469,762,048B) 0x8071180: start_thread (pthread_create.c:312)
    | |     | |   ->29.63% (469,762,048B) 0x578500B: clone (clone.S:111)
 

In order to decrease the memory usage it is possible to set the MALLOC_ARENA_MAX environment value in the nxnode launch script (/etc/NX/nxnode).

For example, add it to the end of the script and before the 'if test $ENABLED_DEBUG = 0;' condition:

[...]
export MALLOC_ARENA_MAX=4

 if test $ENABLED_DEBUG = 0;
 then
   exec "$ROOTDIR/bin/nxnode.bin" "$@"
else
  exec $COMMAND_DEBUG ${PARAMS_DEBUG} "$ROOTDIR/bin/nxnode.bin" "$@"
fi


Restarting NoMachine is not needed, this change will take effect at the next new session.