Hello, my communication layer uses a TWSocket as TCP server socket and one for the actual communication as there will only be one connection at any give time. When the client requests a close of the connection I close the socket and in the OnSessionClosed I free it, because the server socket decides on it being nil or not wether to accept a new incomming session request or not. A invalid request will be temporarily accepted but closed at once.
My problem now is that FastMM reports a memory leak when the application is terminated. The rest of the app. works well enough, I can connect, send the data etc. disconnect, connect again etc. but every time I disconnect memory gets lost (some strings and something unknown, but only a few bytes (always the same amount as it seems)). My TCP-server class (TWSocket descendant) holds a reference to the TWSocket as well which is explicitely set to nil when this socket's OnSessionClosed is called but directly after it a FreeAndNil(self) is called. If I use the full fastMM to trace the memory loss I get something slightly different or all the same that makes me wonder if my socket is freed correctly or who tries to call something from it. Using netstat I can see that the connection properly terminates after some seconds as expected (I only think it takes a little long to update the status display but that's a different matter I think and not avoidable). Here is the fastMM trace (I've cut it after the first few bytes of memory dump as the rest is all 80hex): --------------------------------2007/4/5 15:45:53-------------------------------- FastMM has detected an attempt to call a virtual method on a freed object. An access violation will now be raised in order to abort the current operation. Freed object class: TServerAnswerSocket Virtual method: Offset +180 Virtual method address: 480CC4 The allocation number was: 5218 Stack trace of when the object was allocated (return addresses): 4030C6 [EMAIL PROTECTED] 403FB3 [System][TObject.NewInstance] 40437A [EMAIL PROTECTED] 485A72 [tcpkommunikation.pas][tcpkommunikation][TServerAnswerSocket.Create][435] 486223 [tcpkommunikation.pas][tcpkommunikation][TServerSocket.MyOnSessionAvailable][658] 481161 [WSocket.pas][WSocket][TCustomWSocket.TriggerSessionAvailable][5652] 47E087 [WSocket.pas][WSocket][TCustomWSocket.Do_FD_ACCEPT][4165] 47E17D [WSocket.pas][WSocket][TCustomWSocket.WMASyncSelect][4254] 47CB8B [WSocket.pas][WSocket][TCustomWSocket.WndProc][3174] 483E06 [WSocket.pas][WSocket][TCustomLineWSocket.WndProc][6533] Stack trace of when the object was subsequently freed (return addresses): 4030E2 [EMAIL PROTECTED] 403FD1 [System][TObject.FreeInstance] 4043C5 [EMAIL PROTECTED] 483D92 [WSocket.pas][WSocket][TCustomLineWSocket.Destroy][6516] 404017 [System][TObject.Free] 4149BD [SysUtils][FreeAndNil] 485ED6 [tcpkommunikation.pas][tcpkommunikation][TServerAnswerSocket.MyOnSessionClosed][540] 4811F1 [WSocket.pas][WSocket][TCustomWSocket.TriggerSessionClosed][5675] 4827F7 [WSocket.pas][WSocket][TCustomSocksWSocket.TriggerSessionClosed][6061] 484AF1 [WSocket.pas][WSocket][TCustomLineWSocket.TriggerSessionClosed][6898] The current stack trace leading to this error (return addresses): 47E063 [WSocket.pas][WSocket][TCustomWSocket.Do_FD_CLOSE][4157] 47E1AD [WSocket.pas][WSocket][TCustomWSocket.WMASyncSelect][4261] 47CB8B [WSocket.pas][WSocket][TCustomWSocket.WndProc][3174] 483E06 [WSocket.pas][WSocket][TCustomLineWSocket.WndProc][6533] 47CD07 [WSocket.pas][WSocket][XSocketWindowProc][3225] 77E3158F [GetTopWindow] 77E31DC9 [GetWindowLongW] 77E297D8 [GetParent] 77E193FB [GetPropA] 4732CD [Forms][TApplication.ProcessMessage] Current memory dump of 256 bytes starting at pointer address 2449D50: 0C 1E 50 00 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 Greetings Markus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
