From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 5 09:35:44 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8DDCC16A4DE for ; Sat, 5 Aug 2006 09:35:44 +0000 (UTC) (envelope-from viaprog@betline.ru) Received: from mail.betline.ru (ns.hibet.ru [212.248.26.3]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2269643D46 for ; Sat, 5 Aug 2006 09:35:43 +0000 (GMT) (envelope-from viaprog@betline.ru) Received: from s4.hibet.ru (s4.hibet.ru [212.248.26.95]) by mail.betline.ru (Postfix) with ESMTP id 3A1B010A4C34 for ; Sat, 5 Aug 2006 13:35:41 +0400 (MSD) Date: Sat, 05 Aug 2006 13:35:45 +0400 To: freebsd-hackers@freebsd.org From: "Igor A. Valcov" Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Message-ID: User-Agent: Opera Mail/9.00 (Linux) X-Mailman-Approved-At: Sat, 05 Aug 2006 15:32:54 +0000 Subject: pthreads memoty leak? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Aug 2006 09:35:44 -0000 Hi The startup of this program causes memory leak, doesn't it? What's the = reason? Tested on FreeBSD-6.1 and 5.4 with the same effect. On Linux work fine. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= #include #include #include void* mythread(void* arg) { return NULL; } void threaded() { #define size 1 int ret, i; for (i =3D 0; i < size; i++) { pthread_t t_id; pthread_attr_t pthread_attr; pthread_attr_init (&pthread_attr); pthread_attr_setdetachstate (&pthread_attr, = PTHREAD_CREATE_DETACHED); ret =3D pthread_create (&t_id, &pthread_attr, mythread, NULL);= pthread_attr_destroy (&pthread_attr); if (ret) printf ("pthread_create() returned error value %d\n", ret)= ; } } int main() { int i; for (i =3D 0; i < 10000000; i++) { if (i % 1000 =3D=3D 0) printf ("main() iteration: %d\n", i); threaded(); } printf ("FINISHED.\n"); sleep (3600); return 0; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D -- = Igor A. Valcov