[ENet-discuss] packet->referenceCount greater than zero
Lee Salzman
lsalzman1 at cox.net
Tue Mar 18 15:57:56 PDT 2008
enet_peer_send (..., packet);
if (! packet -> referenceCount) enet_packet_destroy (packet);
Doug Kimzey wrote:
>
> Hello,
>
> I have been troubleshooting a memory leak in my application that uses
> eNet. I suspect that we need to do some cleanup on sent packets but
> would like some guidance – (so please correct me where I am wrong).
>
> · Packets are usually only destroyed when the
> _ENetPacket::referenceCount field is equal to 0
>
> · In walking through my code:
>
> o A packet is successfully created – and the newly created packet has
> a referenceCount of 0
>
> o ::enet_peer_send(…) queues the packet fragments when the packet size
> exceeds the fragment length. For each fragment in the packet,
> ::enet_peer_queue_outgoing_command(…) is called.
>
> o In ::enet_peer_queue_outgoing_command(…):
>
> · An ENetOutgoingCommand is allocated and initialized
>
> · The packet->referenceCount is incremented.
>
> o ::enet_peer_send returns 0 (success)
>
> o My packet->referenceCount is greater than 0 – so my call to
> ::enet_packet_destroy(…) is not made and the packet memory is not freed.
>
> Is there an enet function that should be called after ::enet_peer_send
> that will verify the packet was indeed sent and decrement the
> packet->referenceCount before calling ::enet_packet_destroy?
>
> Thank you,
>
> Doug Kimzey
>
> Doug.kimzey at dpra.com
>
> DPRA, Inc.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
More information about the ENet-discuss
mailing list