Re: HELP!! CSocket and CAsyncSocket Consumes Memory Uncontrollably



Eugene!
Just demystifying CSocket attach :) member : it create socket and window
for notifications and put both ( window and socket ) handles in it's
internal map
Arkady

"Eugene Gershnik" <gershnik@xxxxxxxxxxx> wrote in message
news:exYM6REqFHA.2628@xxxxxxxxxxxxxxxxxxxxxxx
> Roger Garrett wrote:
>
>> pSocket->Detach();
>
> This most likely detaches a C++ CSocket object from OS SOCKET. (I don't
> know what exactly CSocket does but this is the usual MFC naming
> convention)
>
>> pSocket->Close();
>
> This is probably no-op as there is no SOCKET to close in CSocket anymore
>
>> delete pSocket;
>
> And this destroys C++ object while the OS SOCKETS continues to live ;-)
>
> If I am right it gives another reason why MFC's use of double-state
> anti-pattern is a huge mistake.
>
> --
> Eugene
> http://www.gershnik.com
>
>
>
>> }
>>
>> That is, it merely allocates a CSocket and then deletes it.
>> Wnen I go through this loop I can watch the memory usage go up and up.
>> Clearly, the delete of the CSocket is not entirely deleting
>> everything.
>>
>> SAME PROBLEM WITH CAsyncSocket
>>
>> I also tried the very same kind of thing with CAsyncSocket and I get
>> the very same symptoms, of memory constantly increasing for the app.
>>
>> Is there a solution to the problem of not fully deleting CSockets or
>> CAsyncSockets?
>>
>> I really need some help on this.
>
>


.



Relevant Pages

  • Re: Bug with Socket
    ... replace the following functions in MSocketSupport and CSocket. ... are you ignoring any specific socket errors? ... Dim strTemp As String ... Winsock API function ...
    (microsoft.public.vb.bugs)
  • Re: CAsyncSocket in a DLL, frequent crashes on close in DetachHandle
    ... doesn't have a message pump, so my socket was disfunctional - receiving ... my next step was to create and use the CSocket from a separate UI ... that the 'listener' therad was killed before I tried ...
    (microsoft.public.vc.mfc)
  • Re: CSocket
    ... CSocket simulates a blocking socket, ... Your app will stop responding to the ... CSocket is not actually a blocking socket; ...
    (microsoft.public.vc.mfc)
  • Re: CSocket in thread causes debug assertion
    ... No, it didn't "work", it just didn't produce an assertion. ... >> Note that you should not ever use CSocket for serious code. ... Use CAsyncSocket for all socket communications. ... >> You cannot pass a CSocket into a worker thread, nor can you use sockets in worker threads. ...
    (microsoft.public.vc.mfc)
  • Re: Sockets / erste Schritte
    ... die er mit Accept an einen neuen Sockt übergibt. ... >> Client analog zu einem CodeGuru Beispiel geschrieben. ... erstellt die Applikation ein leeres CSocket ... > 1. es wird ein socket s_server erstellt. ...
    (microsoft.public.de.vc)