Vhclient memory leak

Hello i faced with some strange thing on linux vhclient v 4.2.1
I runs as a service, and it consume more and more memory each request to vhclient api
so this is illustration of dynamic of this:


top - 19:04:33 up 1 day, 1:05, 1 user, load average: 0.48, 0.44, 0.42
Tasks: 95 total, 1 running, 94 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.7 us, 6.3 sy, 0.0 ni, 91.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1024812 total, 544444 free, 164032 used, 316336 buff/cache
KiB Swap: 131068 total, 131068 free, 0 used. 826311 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
740 root 20 0 102216 101204 4 S 3.3 9.9 51:50.74 vhclient


top - 19:05:00 up 1 day, 1:05, 1 user, load average: 0.52, 0.45, 0.43
Tasks: 95 total, 1 running, 94 sleeping, 0 stopped, 0 zombie
%Cpu(s): 3.5 us, 8.3 sy, 0.0 ni, 88.1 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st
KiB Mem : 1024812 total, 544460 free, 164056 used, 316296 buff/cache
KiB Swap: 131068 total, 131068 free, 0 used. 826327 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
740 root 20 0 102248 101204 4 S 4.3 9.9 51:51.73 vhclient


top - 19:05:21 up 1 day, 1:06, 1 user, load average: 0.60, 0.47, 0.43
Tasks: 95 total, 1 running, 94 sleeping, 0 stopped, 0 zombie
%Cpu(s): 3.3 us, 6.9 sy, 0.0 ni, 88.9 id, 0.0 wa, 0.0 hi, 0.8 si, 0.0 st
KiB Mem : 1024812 total, 544404 free, 164084 used, 316324 buff/cache
KiB Swap: 131068 total, 131068 free, 0 used. 826271 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
740 root 20 0 102272 101468 4 S 4.0 9.9 51:52.48 vhclient


top - 19:14:22 up 1 day, 1:15, 1 user, load average: 0.24, 0.34, 0.39
Tasks: 94 total, 3 running, 91 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.9 us, 5.4 sy, 0.0 ni, 91.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1024812 total, 544064 free, 164452 used, 316296 buff/cache
KiB Swap: 131068 total, 131068 free, 0 used. 825927 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
740 root 20 0 102836 101996 4 S 2.3 10.0 52:11.26 vhclient

so about 800kb per minute 10 for my case of requests to them ( each 2 seconds), it's a real problem for hosts with small amount of ram (something like rpi )
Can you please give advice how to resolve this issue, or fix this problem.

#2

I'll take a look now and get back to you...

#3

Looking more into this , im pretty sure virtualhere doesnt have a leak here, as valgrind returns 0 leaks (after calling the API 200 times) and many customers use this feature and none have reported leaks. I think possibly you are reading the top results incorrectly. Those are not particularly useful because the kernel swaps in and out pages which changes the memory usage values. If after several days the memory % for the vhclient process is above 10% or so then there might be a leak somewhere in virtualhere or a related library. I was testing on the pi3 with the 4.9 kernel, is that similar to your client machine?

#4

Actually it's orangepi pc board with armbian OS on it,
OS and swap placed on sdcard, and when system starts actively using swap, LA starts grows up to 10.


root@tokenexp01:~# uname -a
Linux tokenexp01 3.4.113-sun8i #10 SMP PREEMPT Thu Feb 23 19:55:00 CET 2017 armv7l armv7l armv7l GNU/Linux

vhclient still running and now vhclient consume about 220Mb of ram, instead of ~ 100 Mb 16 hours ago.


top - 11:58:49 up 1 day, 17:59, 1 user, load average: 0.47, 0.46, 0.48
Tasks: 95 total, 3 running, 92 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.8 us, 7.7 sy, 0.0 ni, 87.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1024812 total, 477596 free, 228464 used, 318752 buff/cache
KiB Swap: 131068 total, 131068 free, 0 used. 760423 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
740 root 20 0 166204 165356 4 R 3.9 16.1 87:09.33 vhclient

#5

What commands are you sending via the api?

#6

Only this 2 commands:
LIST
to retieve list of devices
and after that
DEVICE INFO,servename.location
for each device

#7

@Michael , any update , idea, how it can be fixed - of course i can use "addhoc" solution such as restart vhclient periodically but it's not good idea i think

some results


top - 09:20:29 up 2:12, 1 user, load average: 0.45, 0.47, 0.48
Tasks: 97 total, 1 running, 96 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.9 us, 8.5 sy, 0.0 ni, 86.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1024812 total, 770132 free, 79256 used, 175424 buff/cache
KiB Swap: 131068 total, 131068 free, 0 used. 914580 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
672 root 20 0 17004 15936 4 S 3.9 1.6 4:23.32 vhclient


top - 21:36:27 up 14:28, 1 user, load average: 0.58, 0.48, 0.50
Tasks: 96 total, 1 running, 95 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.9 us, 7.5 sy, 0.0 ni, 89.5 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st
KiB Mem : 1024812 total, 556812 free, 125252 used, 342748 buff/cache
KiB Swap: 131068 total, 131068 free, 0 used. 866027 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
672 root 20 0 62596 61604 4 S 3.3 6.0 29:38.22 vhclient


top - 00:51:29 up 1 day, 17:43, 1 user, load average: 0.42, 0.46, 0.49
Tasks: 94 total, 2 running, 92 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.6 us, 4.6 sy, 0.0 ni, 90.4 id, 0.0 wa, 0.0 hi, 0.5 si, 0.0 st
KiB Mem : 1024812 total, 437092 free, 227716 used, 360004 buff/cache
KiB Swap: 131068 total, 131068 free, 0 used. 761091 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
672 root 20 0 164484 163244 4 S 1.9 15.9 87:12.03 vhclient

after ~ 15 hours about 59MB
after ~ 1 day 18 hours about 160MB ~ 65KB in munute - here i have 8 devices - ~ 9kb per device

on another server i have

top - 23:54:06 up 4 days, 2:59, 1 user, load average: 0.01, 0.04, 0.05
Tasks: 99 total, 1 running, 98 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.7 us, 0.5 sy, 0.0 ni, 98.7 id, 0.0 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem: 1024808 total, 823912 used, 200896 free, 1432 buffers
KiB Swap: 131068 total, 14996 used, 116072 free. 15780 cached Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
605 root 20 0 729088 725612 0 S 0.0 70.8 320:31.03 vhclient

here we see about 700MB after 4 day - and 27 devices ~ 248 KB in minute - here i have 27 devices - ~ 9kb per device

Whats I would to show, that it's not random issue, i have correlation, and i can reproduce it easily.

#8

Sorry yes ill look at this over this weekend, i had some other items come up but they are completed...

#9

OK can you download 4.2.3 of the client now , it should be fixed

#10

Hi Michael.
Thank you so much. I will tested it asap.

#11

Hi Michael.
Everything works fine. Thank you! Issue resolved.

#12

Ok great!