[ENet-discuss] Allocation patterns

Dimitri Kaparis kaparis.dimitri at gmail.com
Thu Feb 10 18:55:44 PST 2011


Greetings,

Since I'm using the ENet library in an embedded realtime system, I've
used the callbacks functionality to implement a custom allocator using
static storage, to avoid memory fragmentation and performance
degradation associated with dynamic memory allocations.
The usage pattern of ENet in my system is like this:
Process A is sending out non-reliable packages of small size to
process B at a rate of approximately 30 packages per second (and
calling enet_host_service at the same rate). Process B is calling
enet_host_service and processing these packages generally at a higher
rate, however it would occasionally lock up doing some other work for
up to a second. After such lock ups I've noticed the enet_host_service
calls sometimes begin to allocate progressively larger and larger
number of memory blocks, reaching thousands of allocations per single
call! The allocated block sizes are small, varying between 20 and 76
bytes.

What is the reason for this behaviour, and is there anything I can do
to restrict such excessive numbers of allocations?
More importantly, since my allocator is using statically allocated
storage, it is crucial to define an upper limit of required memory for
each process, otherwise the process might fail due to lack of memory.
Is there a way I can do that?

Thanks,
Dimitri


More information about the ENet-discuss mailing list