Leonardo choking after a few loop()s

So, I'm making a GPS tracker that sends the data to a server, but after 1-2 loop() cycles of working perfectly(it sends the packages), but then it chokes(stops making output to Serial and does not send anything) Why is this happening and how to fix it? gps is connected through UART via HardwareSerial and gprs also through UART via SoftwareSerial.

the code:

#include <GPRS_Shield_Arduino.h>
#include <TroykaGPS.h>
#include <SoftwareSerial.h>
#define IMEI "IMEI" //I removed the real IMEI 
#define INTERVAL 30000
#define LEN 370
#define MAX_SIZE_MAS 16
char tcpBuffer[LEN];
SoftwareSerial GPRSSerial(10, 11);
GPS gps(Serial1);
GPRS gprs(GPRSSerial);

void setup()
{
    Serial.begin(9600);
    while(!Serial){}
    Serial.println("Serial init OK");
    delay(100);
    Serial1.begin(115200);
    Serial.println("GPS serial init OK");
    GPRSSerial.begin(9600);
    Serial.println("GPRS serial init OK");
    delay(1000);
    Serial.println("Waiting for network");
    while(1){
        delay(1000);
        if(gps.available()){
                gps.readParsing();
                if(gps.getState() == GPS_OK) break;

        }
        else{
            Serial.println("GPS not available");
        }
    }
    Serial.println("Network found!");
}

void loop()
{
    gprs.powerOn();
    while (!gprs.init()) { 
        Serial.println("GPRS Init error");
    }
    Serial.println("GPRS init success");
    delay(3000);
    while (!gprs.join("internet.beeline.ru", "beeline", "beeline")) { 
        Serial.println("GPRS JOINING NETWORK ERROR");
        delay(1000);
    }
    Serial.println("GPRS OK");
    Serial.print("IP Address is ");
    Serial.println(gprs.getIPAddress());
    while (!gprs.connect(TCP, "*ip address*", 80)) { //I replaced the real IP
        Serial.println("Connect error");
        delay(1000);
    }
    Serial.println("Connect success");
    tcpSend();
    gprs.close();
    gprs.disconnect();
    delay(100);
    Serial.println("Sent");
    gprs.powerOff();
    delay(15000);
}

void tcpSend()
{
    tcpBufferForm();
    gprs.send(tcpBuffer);
    clearTcpBuffer();
}

void tcpBufferForm(){
    //strcat(tcpBuffer, "GET /recvdata.php?filename=ard.txt&data=123 HTTP/1.0\r\n\r\n");
    char buf[100];
    if (gps.available()) {
        gps.readParsing();
        switch(gps.getState()) {
            case GPS_OK:
                char lon[16], lat[16], date[16], time[16];
                gps.getTime(time, MAX_SIZE_MAS);
                gps.getDate(date, MAX_SIZE_MAS);
                dtostrf(gps.getLatitudeBase10(), 9, 6, lat);
                dtostrf(gps.getLongitudeBase10(), 9, 6, lon);
                sprintf(tcpBuffer, "GET /recvdata.php?filename=%s_%s.txt&data=%s_%s_%s_%s_%s HTTP/1.0\r\n\r\n", date, time, IMEI, date, time, lat, lon);
                Serial.print("formed: ");
                Serial.println(tcpBuffer);
                Serial.print("pending to send...");
                break;
            case GPS_ERROR_DATA:
                gprs.getDateTime(buf);
                sprintf(tcpBuffer, "GET /recvdata.php?filename=%s_err.txt&data=ERROR_DATA_%s_%s HTTP/1.0\r\n\r\n", buf, buf, IMEI);
                Serial.println("Sending GPS_ERROR_DATA");
                Serial.print("formed: ");
                Serial.println(tcpBuffer);
                Serial.print("pending to send...");
                break;
            case GPS_ERROR_SAT:
                gprs.getDateTime(buf);
                sprintf(tcpBuffer, "GET /recvdata.php?filename=%s_err.txt&data=ERROR_SAT_%s_%s HTTP/1.0\r\n\r\n", buf, buf, IMEI);
                Serial.println("Sending GPS_ERROR_SAT");
                Serial.print("formed: ");
                Serial.println(tcpBuffer);
                Serial.print("pending to send...");
                break;
        }
    }
}

void clearTcpBuffer()
{
    for (int t = 0; t < LEN; t++) {
        tcpBuffer[t] = 0;
    }
}

GPS gps(Serial1); ?

What ?