From owner-freebsd-questions@FreeBSD.ORG Fri Jun 11 20:14:18 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B81711065674 for ; Fri, 11 Jun 2010 20:14:18 +0000 (UTC) (envelope-from Vikash.Badal@is.co.za) Received: from morpheus.is.co.za (morpheus.is.co.za [196.35.45.229]) by mx1.freebsd.org (Postfix) with ESMTP id 3202D8FC1E for ; Fri, 11 Jun 2010 20:14:17 +0000 (UTC) Received: from morpheus.is.co.za (localhost.is.co.za [127.0.0.1]) by morpheus.is.co.za (Postfix) with ESMTP id 0E089F3FE3; Fri, 11 Jun 2010 22:14:16 +0200 (SAST) Received: from ZABRYSVISMFW3 (zajnbisit03.mfw.is.co.za [196.26.2.110]) by morpheus.is.co.za (Postfix) with ESMTP id D560CF3FDF; Fri, 11 Jun 2010 22:14:15 +0200 (SAST) Received: from zabrysvisexhub2.af.didata.local (Not Verified[10.1.8.39]) by ZABRYSVISMFW3 with MailMarshal (v6, 5, 4, 7535) id ; Fri, 11 Jun 2010 22:13:30 +0200 Received: from ZABRYSVISEXMBX1.af.didata.local ([fe80::914a:a14c:13c1:d279]) by zabrysvisexhub2.af.didata.local ([fe80::486:fd5b:97f4:6b92%10]) with mapi; Fri, 11 Jun 2010 22:13:33 +0200 From: Vikash Badal To: Dan Nelson Date: Fri, 11 Jun 2010 22:14:13 +0200 Thread-Topic: threads and malloc/free on freebsd 8.0 Thread-Index: AcsJoER5Jhvxl12XQAqKq3uBOAXeBgAANYMQ Message-ID: <9B425C841283E0418B1825D40CBCFA613D9E3CA644@ZABRYSVISEXMBX1.af.didata.local> References: <9B425C841283E0418B1825D40CBCFA613D9E3CA643@ZABRYSVISEXMBX1.af.didata.local> <20100611195628.GB36450@dan.emsphone.com> In-Reply-To: <20100611195628.GB36450@dan.emsphone.com> Accept-Language: en-US, en-ZA Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, en-ZA Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP Cc: "freebsd-questions@freebsd.org" Subject: RE: threads and malloc/free on freebsd 8.0 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2010 20:14:18 -0000 > -----Original Message----- > From: owner-freebsd-questions@freebsd.org [mailto:owner-freebsd- > questions@freebsd.org] On Behalf Of Dan Nelson > Sent: 11 June 2010 09:56 PM > To: Vikash Badal > Cc: freebsd-questions@freebsd.org > Subject: Re: threads and malloc/free on freebsd 8.0 >=20 =20 > The fix is to remove your second call to malloc_usable_size(z)). Then > neither version will crash. Also, a useful habit to start is to > explicitly > zero the pointer you just free'd, to prevent it from being used > accidentally > later. Made this change: ----------- =20 LogMessage(DEBUG_0, "allocated %ld", malloc_usable_size(inst)); =20 =20 =20 free(inst); =20 free(inst); =20 =20 =20 return 0; ----------- Still no seg fault. The reason im am doing this is that from top I can see the memory grow as= =20I connect to this app. When I disconnect, the memory used ( as displayed from top ) does not dec= rease. I tried: ------------- char *chunk; chunk =3D (char*) malloc(1200000); sleep(30); free(chunk) sleep(30); free(inst); free(inst); ------------------ Top show the memory for the chunk section increase and then decrease whe= n freed However, the when I leave the worker thread ( close the connection ), the= =20memory usage does not decrease. The more connections I open and close, the faster the memory grows. >=20 > -- > Dan Nelson > dnelson@allantgroup.com > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions- > unsubscribe@freebsd.org" Please note: This email and its content are subject to the disclaimer as = displayed at the following link http://www.is.co.za/legal/E-mail+Confiden= tiality+Notice+and+Disclaimer.htm. Should you not have Web access, send a= =20mail to disclaimers@is.co.za and a copy will be emailed to you.