Hello Arno, Thank you for responding.
I see what you are saying. And as you assumed this is happening while closing down. And indeed windows will free the memory the application did not free explicitly. The thing is that if you leave the freeing up to windows you have no means of checking for memory leaks. So I like my programs to free all their memory so I'm sure I haven't forgotten anything. If the client still lives then the owner, the server, must be alive also. As far as I can tell the message postmessage sends (posts :-) ) is not handled (anymore) so this memory won't get freed. Could it be the hidden window is destroyed before the socket server is? Regards, Henk van der Meer -----Oorspronkelijk bericht----- Van: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] Namens Arno Garrels Verzonden: woensdag 21 september 2011 16:10 Aan: ICS support mailing Onderwerp: Re: [twsocket] Loosing memory in TWSocketClient.TriggerSessionClosed 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 -- 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