I've written a server and client program using CSockets. (I didn't come
across the "Don't ever do that" postings about CSockets until I was deep into
the implementation).
My programs work quite well. But they continually consume more and more
memory until the whole thing crashes. If I stop it at some point (while
debugging with the VS IDE) and return to the IDE, it never reports any memory
leaks. Yet, when I run the program and watch the memory usage of the
application via the Windows Task Manager I can see its memory usage going up
and up and up endlessly.
I did some tests that are basically:
int n;
for (n = 0 ; n < 10000 ; +=n)
{
CSocket* pSocket = CSocket*) new CSocket;
pSocket->Create(0);
delete pSocket;
}
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.
And I get the same kind of issues with CSocketFile and CArchive. They all
fail to fully delete.
My application absolutely MUST be able to create CSockets and CSoekctFiles
and CArchive as needed, since it's a Server.
Is there a solution to the problem of not fuilly deleting CSockets, etc.?