Re: Memory leak with CAsyncSocket::Create
- From: "Michael K. O'Neill" <MikeAThon2000@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 10 Jul 2007 13:45:46 -0700
"r norman" <r_s_norman@xxxxxxxxxxxx> wrote in message
news:2895939efidggi556s7fbje0euhm2jd2d0@xxxxxxxxxx
I have traced a memory leak problem to CAsyncSocket::Create(). Is
this a known problem? Is there a workaround/solution/fix? Here is
sample code:
for (int i=0; i<m_nReopenCount; ++i) {
CAsyncSocket *pAS = new CAsyncSocket;
pAS->Create();
pAS->Close();
delete pAS;
}
Running this 1000 times uses up 1200 KBytes of memory, or just over 1
KByte per call. Commenting out the Create() leaves memory clean. (And
please don't complain about my bracketing style -- I like it.)
This is a known problem, acknowledged by Microsoft.
Apparently, when using CAsyncSocket in a GUI app that also has XP visual
styles (themes), there is a memory leak. The problem seems to be
OS-dependent, and it might exist only under XP (running themes). It did not
manifest itself under Win 2000, and it might be gone now from Vista.
For one report, see "CSocket Consuming Memory Uncontrollably" at
http://www.codeguru.com/forum/showthread.php?t=353944 . I am fairly certain
that this is the same problem that you are seeing, since this report also
includes the exact same number for the amount of leaked memory (i.e., 1200
bytes per call to Create()).
There is a parallel posting in the newsgroups at "HELP!! CSocket and
CAsyncSocket Consumes Memory Uncontrollably" in the
microsoft.public.win32.programmer.networks newsgroup, at
http://groups.google.com/group/microsoft.public.win32.programmer.networks/browse_frm/thread/8490cdb5c4f18c76/b87332dbee0cb54c?tvc=1
The "solution", if you can call it that, is to disable themes. See
"CAsynCSocket Memory Leak Fix" at
http://www.codeguru.com/forum/showthread.php?t=370761
Mike
.
- Follow-Ups:
- Re: Memory leak with CAsyncSocket::Create
- From: Doug Harrison [MVP]
- Re: Memory leak with CAsyncSocket::Create
- From: r norman
- Re: Memory leak with CAsyncSocket::Create
- References:
- Memory leak with CAsyncSocket::Create
- From: r norman
- Memory leak with CAsyncSocket::Create
- Prev by Date: Re: New essay: ToString
- Next by Date: Re: New essay: ToString
- Previous by thread: Re: Memory leak with CAsyncSocket::Create
- Next by thread: Re: Memory leak with CAsyncSocket::Create
- Index(es):
Relevant Pages
|
Loading