Re: HELP!! CSocket and CAsyncSocket Consumes Memory Uncontrollably



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: csocket or Asyncsocket
    ... I wouldn't recommend using MFC (CSocket, CAsyncSocket). ... blocking socket is just a perversion if you ask me). ...
    (microsoft.public.win32.programmer.networks)
  • Re: Something like "ping" for windows messages.
    ... My background is programming on UNIX with servers that have to run on ... so I've never seen this problem with CAsyncSocket. ... And what does deriving a class from CSocket and CWnd have to do with any perceivable form ... And he reports that it has bugs, which is well-known to socket programmers. ...
    (microsoft.public.vc.mfc)
  • Re: how to block CAsyncSocket Receive
    ... On accept, the receiving code ... > this reply and CAsyncSocket doesn't do that. ... > plunge into CSocket world? ... Sychronous socket design has an inherant flaw: ...
    (microsoft.public.vc.mfc)
  • Re: Using CSocket calls in COM+ DLL blocking IIS 6.0
    ... Don't use CSocket. ... Either use CAsyncSocket, or use the WinSock ... blocking socket abstraction, but based on CAsyncSocket, ... A furhter piece of advice - move all networking code to a ...
    (microsoft.public.vc.atl)
  • 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)

Loading