title: Linux: proc/net/sockstat tcp mem more and more larger
body: <p>Now, our system find hang and tcp mem more and more larger through <code>/proc/net/sockstat</code>. when hang appear, will print :</p>
  <blockquote>
  <p>&quot;tcp:too many of orphaned sockets&quot;</p>
  </blockquote>
  <p>From <code>sockstat</code>, we know there are few socket, but consumes 1500 page mem, why ?</p>
  <p>So I have 2 questions :</p>
  <ol>
  <li>How to know Which process consumes tcp socket memory?</li>
  <li>How to avoid &quot;tcp:too many of orphaned sockets&quot;?</li>
  </ol>
  <p>(1)</p>
  <pre><code>~ # cat /proc/net/sockstat
  
  sockets: used 56
  
  TCP: inuse 6 orphan 0 tw 1 alloc 8 mem 1510
  
  UDP: inuse 8 mem 6
  
  UDPLITE: inuse 0
  
  RAW: inuse 4
  
  FRAG: inuse 0 memory 0
  </code></pre>
  <p>(2)</p>
  <pre><code>~ # cat /proc/sys/net/ipv4/tcp_mem
  
  900     1200    1800
  
  ~ # cat /proc/sys/net/ipv4/tcp_rmem
  
  4096    87380   87380
  
  ~ # cat /proc/sys/net/ipv4/tcp_wmem
  
  4096    16384   65536
  </code></pre>