Date: Fri, 11 Jun 2010 22:14:13 +0200 From: Vikash Badal <Vikash.Badal@is.co.za> To: Dan Nelson <dnelson@allantgroup.com> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: RE: threads and malloc/free on freebsd 8.0 Message-ID: <9B425C841283E0418B1825D40CBCFA613D9E3CA644@ZABRYSVISEXMBX1.af.didata.local> In-Reply-To: <20100611195628.GB36450@dan.emsphone.com> References: <9B425C841283E0418B1825D40CBCFA613D9E3CA643@ZABRYSVISEXMBX1.af.didata.local> <20100611195628.GB36450@dan.emsphone.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> -----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: <CODE>----------- =20 LogMessage(DEBUG_0, "allocated %ld", malloc_usable_size(inst)); =20 =20 =20 free(inst); =20 free(inst); =20 =20 =20 return 0; -----------</CODE> 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: <CODE>------------- char *chunk; chunk =3D (char*) malloc(1200000); sleep(30); free(chunk) sleep(30); free(inst); free(inst); ------------------</CODE> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9B425C841283E0418B1825D40CBCFA613D9E3CA644>