> Please, how is the realy right way to free the
> TWSocket objects ?

Like any other object instance ! One gold rule being to not destroy an
object from one of his event handlers or you'll get all kind of exceptions
and strange behaviour. Technically, an event handler is just a method call
from the component code. If you destroy the object while in one of his
methods, then when the method returns, the code has an invid "self"
reference and so produce access violations and other errors. This is not
specific to TWSocket, this is how Delphi language works. And this is why a
TForm has a Release method, and why TWSocket has also one.

> It seems that Release doesn't do anything...

As Wilfried said, Release will defer destruction until all currently waiting
events has been processed, this will make sure that the current event
handler is terminated before destroying the object. Release post a message
to the message queue. For release to work, you have to have the message pump
running. The actual destruction will take place later...

--
francois.pie...@overbyte.be
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be

----- Original Message ----- 
From: "Markus Mueller" <twsoc...@priv.de>
To: "ICS support mailing" <twsocket@elists.org>
Sent: Wednesday, February 18, 2009 9:47 AM
Subject: Re: [twsocket] Freeing of sockets


This also don't work. I never see my (extended) destructor beeing called,
if it is called "Free" nor "Destroy". Also my memory usage is increasing
if I just do "release". If I do Free I get memory errors but the memory
usage is not increasing.

Please, how is the realy right way to free the TWSocket objects ? It seems
that Release doesn't do anything...

Much regards,
Markus Müller
> Destructor must be called "Destroy", not "Free"
>
> Markus Mueller wrote:
>
>> Hi Wilfried,
>>
>> I have created an destructor Free, which inherited runs Free of
>> TWSocket. This
>> Free is never called; can anybody tell me why?
>>
>> Are you realy sure it is freed by calling Release if it is never calling
>> Free?!
>>
>> Regards,
>> Markus Mueller
>>
>>
>>> Hello Markus,
>>>
>>> you have to destroy it outside an event handler. to do that you can call
>>> the Release method. Then it is destroyed when messages are pumped again,
>>> so after your code finish.
>>>
>>> ---
>>> Rgds, Wilfried [TeamICS]
>>> http://www.overbyte.be/eng/overbyte/teamics.html
>>> http://www.mestdagh.biz
>>>
>>> Tuesday, February 17, 2009, 10:40, Markus Müller wrote:
>>>
>>>
>>>
>>>
>>>> Hello Mailinglist,
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>> my project is now just working great, thanks very much for your
>>>> help... but there is just one question. Cause it only works fine
>>>> if I don't free TWSocket objects. If I Free them it often works
>>>> fine. But in much cases - for example - in the OnSessionClose
>>>> Handler (the memory of the handler is provided by an other Object
>>>> not beeing freed) then I get strange behaviors. Sometimes it gives
>>>> memory errors on "InternalClose" functions, sometimes the application
>>>> just freezes completely (strange cause all TWSocket is in an own
>>>> thread) and Delphi crashes the hard way...
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>> If I do "Abort" on an TWSocket, then the following lines are not
>>>> running... It seems that it calls "exit" withing the function? So my
>>>> "Free" is never reached. In this case I have completly no idear
>>>> how to Free such a socket....
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>> So my question is: How can I free a TWSocket object after the
>>>> connection has been closed, aborted or the handler reports that
>>>> the session has been closed.
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>> Thanks for hints,
>>>> Much regards,
>>>> Markus Mueller
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>

-- 
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

Reply via email to