[asterisk-dev] chan_sip.c - struct sip_pvt is very large...

Luigi Rizzo rizzo at icir.org
Sun Nov 12 13:41:31 MST 2006


at first i missed it, but when i recently started playing with
the new container code it struck my eyes that
struct sip_pvt has size 5472 bytes (more if you include the lock and
link field).

The culprit seems to be this large field
	struct sip_request initreq
which alone consumes 4644 bytes (4096 of which are for
the packet buffer, sized SIP_MAX_PACKET)

Given that this is always initialized from a known message
in initialize_initreq(), would it make sense to allocate it
with the exact size rather than with the default maximum size ?
Besides, this would also save time in initializing it,
as we don't have to copy the full block but only the data
actually used.

I have no idea how many of these structs can be active for
a busy server, but certainly it seems that we can save a
lot of memory here...

	cheers
	luigi


More information about the asterisk-dev mailing list