Memory leak about TCP slab which have too big used sockets
by mingkunbian from LinuxQuestions.org on (#5DAAF)
Memory leak occurred in linux of 4.18.16, we use nginx as a server, I found some problems related to TCP as following:
1. slabtop a:
OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME
14081971 13980986 99% 2.06K 938799 15 30041568K TCP
2. cat /proc/meminfo
SUnreclaim: 31405028 kB
3. cat /proc/net/sockstat
sockets: used 13976123
TCP: inuse 18 orphan 0 tw 44 alloc 18 mem 1
UDP: inuse 54 mem 45
UDPLITE: inuse 0 RAW: inuse 9
FRAG: inuse 0 memory 0
As above, it seems that tcp sock memory leak, "sockets: used 13976123" illustrate that "net->core.sock_inuse" is too big, which increase in inet_create(socket create) or sk_clone_lock(child socket create) and decrease in __sk_free, I kill almost all of application layer program, but the "sockets: used" almostly not reduce.
Do you have any suggestions for this problem, Thanks.


1. slabtop a:
OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME
14081971 13980986 99% 2.06K 938799 15 30041568K TCP
2. cat /proc/meminfo
SUnreclaim: 31405028 kB
3. cat /proc/net/sockstat
sockets: used 13976123
TCP: inuse 18 orphan 0 tw 44 alloc 18 mem 1
UDP: inuse 54 mem 45
UDPLITE: inuse 0 RAW: inuse 9
FRAG: inuse 0 memory 0
As above, it seems that tcp sock memory leak, "sockets: used 13976123" illustrate that "net->core.sock_inuse" is too big, which increase in inet_create(socket create) or sk_clone_lock(child socket create) and decrease in __sk_free, I kill almost all of application layer program, but the "sockets: used" almostly not reduce.
Do you have any suggestions for this problem, Thanks.