Talloc memory overhead vs malloc

tridge at samba.org tridge at samba.org
Sun Jan 24 16:48:16 MST 2010


Hi John,

 >   * What is the memory overhead per allocation compared to malloc?

On a 32 bit system it is 40 bytes per allocation.

On a 64 bit system it is 72 bytes per allocation 

(assuming no additional padding in the architecture).

 >   * Could I tweak it to use less, for example lose the filename/line
 >     number information (and use something like
 >     __builtin_return_address() instead)

the filename/line information uses 1 pointer, the same as
__builtin_return_address would use.

You could modify the code to remove the pool and refs elements pretty
easily, saving two pointers (with the loss of references and
pools). You could also remove destructors quite easily.

Rusty and I have been thinking about ways of lowering the overhead by
only consuming header bytes when a feature is used, but that work is
not done yet (we don't even have a good design for it worked out
yet). The tricky part is what happens when a pointer that doesn't use
a feature gets that feature added. Moving the pointer would break
existing stack/structure copies of the pointer.

We could instead break the header away from the content, having the
header stored in a separate list of headers in a "header page", and
have only a single pointer stored in the main allocation. That allows
headers to be expanded without breaking existing pointer copies. That
is what we will probably end up doing, but we are a long way from
implementing it.

Cheers, Tridge


More information about the samba-technical mailing list