From owner-freebsd-net@FreeBSD.ORG Thu Jun 19 05:20:46 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8705937B401 for ; Thu, 19 Jun 2003 05:20:46 -0700 (PDT) Received: from mail.sandvine.com (sandvine.com [199.243.201.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1364143FE9 for ; Thu, 19 Jun 2003 05:20:45 -0700 (PDT) (envelope-from sloach@sandvine.com) Received: by mail.sandvine.com with Internet Mail Service (5.5.2653.19) id ; Thu, 19 Jun 2003 08:20:41 -0400 Message-ID: From: Scot Loach To: "'freebsd-net@freebsd.org'" Date: Thu, 19 Jun 2003 08:20:34 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Subject: socket leak in FreeBSD 4.7 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jun 2003 12:20:46 -0000 If I execute the following program on a FreeBSD 4.7 system: int main() { for (int i = 0; i < 70000; i++) { socket(PF_INET, SOCK_STREAM, 0); } return 0; } the sockets never seem to be freed. vmstat tells me the memory is still in use: bash-2.05a$ vmstat -z ITEM SIZE LIMIT USED FREE REQUESTS tcpcb: 544, 106000, 65557, 4474, 70029 udpcb: 192, 106000, 7, 35, 481 unpcb: 160, 0, 7, 43, 78 socket: 192, 106000, 65571, 4487, 70639 However, fstat and sockstat do not show a large number of sockets. netstat shows them, and they look like this: tcp4 0 0 *.* *.* CLOSED If I explicitly close the sockets before the program exits, this does not occur. However I'm worried about the case where a high-volume server exits unexpectedly and leaks sockets. Any ideas of what might be wrong?