malloc options

Kris Kennaway kris at FreeBSD.org
Sun Jul 27 00:10:37 UTC 2008


Doug Hardie wrote:
> I have a program that has run correctly since FreeBSD 3.7.  However, 
> when upgrading the server to 7.0 I am encountering issues where values 
> just seem to arbirtrarily change.  These values are all located in 
> memory allocated by malloc.  Malloc was significantly changed with 7.0 
> and reading through the malloc man page there are a number of flags that 
> can be set with /etc/malloc.conf.  The default for that file is to not 
> exist.  The man page does not indicate which settings are used in that 
> situation.  After reading through it I get the feeling that the default 
> settings for D and M are 'dM'.  Hence, to return to the older malloc 
> aproach to see if the problems go away I would need to set "Dm".  But 
> some of the descriptions seem to indicate that might not be correct.  
> What are the default settings?

I don't think those are the right questions to be asking.

Firstly, if you did not recompile the program under 7.0 then it is not 
using the new malloc at all.

If you did recompile it and it is behaving differently then it is 
probably because your program contains bugs in how it manages memory 
that happened to be working by accident with the old memory allocator. 
e.g. because you were making use of memory after it had been freed, but 
before the allocator returned it to some other malloc() call.

Finally, there is no way to revert to the "old approach" because the new 
allocator is completely new; it allocates memory based on its own 
strategy.  None of the malloc options affect the behaviour of correct 
programs (but some of them can help to improve performance, or to debug 
incorrect programs).

Kris


More information about the freebsd-questions mailing list