C++ Winsock2 connect() loop leads to huge memory consumption

This is my first time coding something using WinSock2 and I tried making a simple chat program which should detect if the server disconnected and then should try to reconnect until a successful connection has been made. (Also: the client connects to server via a No-IP DNS) This is the code:

main.cpp:

void keepAliveSEND(const char* IP, int port) {
    TCPClient ack(IP, port);
    ack.connecttcp();
    while (true) {
        ack.synchronizeSEND();
        ack.synchronizeGET();
    }
}

void keepAliveGET(TCPClient* client, const char* IP, int port) {
    TCPClient ack(IP, port);
    ack.connecttcp();

    unsigned long nonblock = 1;
    ioctlsocket(ack.ssocket, FIONBIO, &nonblock);

    while (true) {
        auto t1 = std::chrono::high_resolution_clock::now();
        bool loop = true;
        bool timeout = true;
        while (loop) {
            char recvbuff[1024];
            int ByteReceived = 0;
            ByteReceived = recv(ack.ssocket, recvbuff, sizeof(recvbuff), 0);
            if (ByteReceived > 0) {
                std::string str = "";
                for (int i = 0; i < ByteReceived; i++) {
                    str += recvbuff[i];
                }
                timeout = false;
            }
            auto t2 = std::chrono::high_resolution_clock::now();
            auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1);
            long ldur = duration.count();
            if (ldur >= 2000) {
                loop = false;
                if (timeout) {
                    client->reconnect();
                    ack.reconnect();
                }
            }
        }
        ack.synchronizeSEND();
    }
}

int main() {
    using namespace std;
    TCPClient client(DNS, 4444);
    client.connecttcp();
    thread t(keepAliveGET, &client, DNS, 4443);
    thread t2(keepAliveSEND, DNS, 4442);
    while (true) {
        //Chat-Code only active upon succesful connection and startchat-command from user
    }

    return 0;
}

TCPClient.cpp:

void TCPClient::connecttcp() {
    WSAStartup(MAKEWORD(2, 2), &wsaData);
    ADDRINFO hints;
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;
    hints.ai_protocol = IPPROTO_TCP;

    ADDRINFO *res;
    getaddrinfo(HostIP, NULL, &hints, &res);
    char ipbuf[INET_ADDRSTRLEN];
    InetNtop(AF_INET, &((SOCKADDR_IN*)res->ai_addr)->sin_addr, ipbuf, sizeof(ipbuf));
    this->IP = ipbuf;

    ssocket = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, NULL, NULL);

    ServerAddr.sin_family = AF_INET;
    ServerAddr.sin_port = htons(port);
    InetPton(AF_INET, (PCSTR)IP, &ServerAddr.sin_addr.s_addr);

    while (connect(ssocket, (SOCKADDR*)&ServerAddr, sizeof(ServerAddr)) == SOCKET_ERROR) {
        Sleep(1000);
    }
}

void TCPClient::reconnect() {
    closesocket(ssocket); //EDIT1: Added this line, doesn't change anything
    while (connect(ssocket, (SOCKADDR*)&ServerAddr, sizeof(ServerAddr)) == SOCKET_ERROR) {
        Sleep(1000);
    }
}


void TCPClient::synchronizeSEND() {
    sendData("ACK");
}

void TCPClient::synchronizeGET() {
    while (true) {
        std::string Ack = receiveData(3);
        if (Ack == "ACK") {
            return;
        }
    }
}

void TCPClient::closeConnection() {
    closesocket(ssocket);
    WSACleanup();
}

When the server closes and then starts again it will listen on port 4444,4443&4442 for ingoing connections and this is why I want to call connect() to reconnect.

When connecttcp() is called for the first time (upon execution) only 0.9MB RAM are being used up by this process. But as soon as the server disconnects and thus reconnect() is called the RAM starts rising quite a bit reaching almost 1.5GB in about 15 seconds which is not acceptable behaviour. I tried to debug the code in Visual Studio an it seems that connect(ssocket, (SOCKADDR*)&ServerAddr, sizeof(ServerAddr)) is causing the memory to go up. But it's still able to reconnect...

I already tried to call closesocket(ssocket) before reconnecting but that didn't help either... I read somewhere that Winsock waits up to 4min before it frees the connect() resources. Could that be why it behaves like that?

How can I solve this sort of thing?