Henk van der Meer wrote:
> Hello,
> I have an application that uses fastmm4 to track memory.
> It informed me of an memory leak that I traced down to: 
> TWSocketClient.TriggerSessionClosed 
> This procedure does a New(PIdRec);
> This record is only disposed of when the postmessage returns true.

No quite correct, if PostMessage returns False the memory is freed
at once, if PostMessage returns True it's freed in the message
handler, so a leak can only occur if PostMessage returned True
and the message is never processed, that however can most
likely only happen when the TWSocketServer object is destroyed. 
> In my program this isn't the case.
> Does somebody know how this is supposed to work?

I guess yuo see this leak once when the application shuts down,
if that is the case no worry, windows frees everything.

> One other thing I noticed. This record contains a reference to the
> client socket. 
> When this message that is posted is processed to late this socket
> does not exist anymore. 

This message is sent to TWSocketServer's hidden window. On receipt
the sending client object is removed from the client list and freed. So
basically one should not free a client object but rather close its
connection. One should also disconnect all clients before the
application shuts down IMO.

> Is there some convention I have to follow in creating and destroying
> clients? 

Let TWSocketServer manage the client objects, it creates them so
it should free them as well. 
Arno Garrels
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to