threads and malloc/free on freebsd 8.0

Vikash Badal Vikash.Badal at
Fri Jun 11 20:14:18 UTC 2010

> -----Original Message-----
> From: owner-freebsd-questions at [mailto:owner-freebsd-
> questions at] On Behalf Of Dan Nelson
> Sent: 11 June 2010 09:56 PM
> To: Vikash Badal
> Cc: freebsd-questions at
> 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:

   LogMessage(DEBUG_0, "allocated %ld", malloc_usable_size(inst));
    return 0;

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:

char *chunk;
chunk = (char*) malloc(1200000);



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
> _______________________________________________
> freebsd-questions at mailing list
> To unsubscribe, send any mail to "freebsd-questions-
> unsubscribe at"
Please note: This email and its content are subject to the disclaimer as displayed at the following link Should you not have Web access, send a mail to disclaimers at and a copy will be emailed to you.

More information about the freebsd-questions mailing list