Original Post
I've got this really weird problem, which I can't wrap my head around: I allocate a few winsock SOCKET wrappers as follows: Socket** stock = new Socket*[stocksize]; for (int x = 0; x < stocksize; x++) stock[x] = new jws::Socket(); And I remove them all in a similar fashion. for (int x = 0; x < stocksize; x++) if (stock[x]) delete stock[x]; The problem is that I have to explicitly delete all of them or else MSVS tells me the heap is corrupted. so this: for (int x = 0; x < stocksize-1; x++) stock[x] = new jws::Socket(); gives errors as during wrapup. But the above ONLY happens if I use the wrapped socket in a Winsock API. If I just allocate the Sockets, nothing bad happens. More precisely, it only seems to happen when I run the Socket object through the following function sometime during the execution: AcceptEx(socket->_getWinSocket(), sock->_getWinSocket(), buf, 0, sizeof(sockaddr_in) + 32, sizeof(sockaddr_in) + 32, &recv, (&ola.ol)); Where _getWinsocket() returns the wrapped SOCKET object/handle. Am I allocating the sockets wrong or something? I really can't figure it out. Maybe I'm missing something... Using the latest MSVS 2005.