[zeromq-dev] Questions about Coding Style

john skaller skaller at users.sourceforge.net
Sat Feb 11 21:37:58 CET 2012

On 12/02/2012, at 7:21 AM, niXman wrote:

> The problem with dangling pointers can only be solved using its own
> allocator.

Sort of. You don't need to actually write an allocator.
It is enough to trace all constructed sockets.

This won't stop memory corruption of a legitimately constructed
live socket. Neither will a custom allocator.

However I take the view that malloc is already pretty good.
I don't know if it actually is, but it is managed by people that
care a lot about efficiency and probably already provide
checks (on my Mac I actually get "free pointer not allocated"
indicating some checks are being done already).

If you want a fast allocator, you have to use TLS to avoid locks.
You're allocating excess storage. If your application is using a lot
of libraries all with their own allocators .. you're actually *causing*
fragmentation and wasting memory.

A library cannot replace "malloc", only a framework should do that.
libgc does it, but then it's really a framework.

But I'm guessing .. always worth looking at a design proposal.

john skaller
skaller at users.sourceforge.net

More information about the zeromq-dev mailing list