[ENet-discuss] ENet performance (packet reuse/allocation, channel count...)

Lee Salzman lsalzman1 at cox.net
Mon May 1 21:53:05 PDT 2006


One way would be to increment the packet's referenceCount field right 
after you create it, so it does not get destroyed. Then keep a list of 
these packets. Every so often, after an enet_host_service, run through 
the list and check for any packets with referenceCount == 1. If so, 
destroy the packet and then you can unpin the memory.

That's if you don't want to modify ENet. The better option would be to 
simply modify enet_packet_destroy() to do what you need. ENet is made to 
be mutilated.

Lee

Kevin Gadd wrote:
> This looks great - one question, though. Is there any straightforward 
> way of detecting when a block of memory is no longer being used by a 
> packet so that I can free up that memory? Getting a 'type' argument to 
> the free() callback would be sufficient, but it might also be nice to 
> just have a specialized 'packetDestroyed' callback that lets the user 
> know that a packet's data is no longer in use.
> 
> In my specific case, to be able to pass a data pointer to enet, I have 
> to pin the data in memory first because I'm using a garbage-collected 
> VM, so I need to know when the data is no longer in use so that it can 
> be unpinned and GCed.
> 
> Thanks
> -k
> 
>


More information about the ENet-discuss mailing list