get size of malloc'd object

Andrew Koenig ark at alice.UucP
Wed Jun 25 23:17:08 AEST 1986


> One nasty efficiency quirk probably ought to be mentioned.  The schemes which
> add extra user information to remember the size of the object are okay,
> modulo some pointer alignment details.  Care with the size of the objects
> may be needed if you are allocating lots of them, though.  Some memory
> allocators allocate things in fixed sizes, such as power-of-two minus some
> internal overhead. If a program is allocating funny sized buffers scaled to
> cooperate with brain damaged allocators, and then adds extra overhead, the
> resulting size may cause poor allocators to waste lots of space.  Of course,
> 'knowing' the size of blocks actually allocated is not portable. But if you
> are tight on address space or physical memory, it could matter.

Translated into English, this says:

	Some memory allocators are broken.  Thus we should all
	warp our programs into forms that work well with these
	broken memory allocators.



More information about the Comp.unix mailing list