threads and malloc/free on freebsd 8.0
Vikash Badal
Vikash.Badal at is.co.za
Fri Jun 11 20:14:18 UTC 2010
> -----Original Message-----
> From: owner-freebsd-questions at freebsd.org [mailto:owner-freebsd-
> questions at freebsd.org] On Behalf Of Dan Nelson
> Sent: 11 June 2010 09:56 PM
> To: Vikash Badal
> Cc: freebsd-questions at freebsd.org
> Subject: Re: threads and malloc/free on freebsd 8.0
>
> 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>-----------
LogMessage(DEBUG_0, "allocated %ld", malloc_usable_size(inst));
free(inst);
free(inst);
return 0;
-----------</CODE>
Still no seg fault.
The reason im am doing this is that from top I can see the memory grow as I connect to this app.
When I disconnect, the memory used ( as displayed from top ) does not decrease.
I tried:
<CODE>-------------
char *chunk;
chunk = (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 when freed
However, the when I leave the worker thread ( close the connection ), the memory usage does not decrease.
The more connections I open and close, the faster the memory grows.
>
> --
> Dan Nelson
> dnelson at allantgroup.com
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-
> unsubscribe at 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+Confidentiality+Notice+and+Disclaimer.htm. Should you not have Web access, send a mail to disclaimers at is.co.za and a copy will be emailed to you.
More information about the freebsd-questions
mailing list