SD card reader and ESP8266 not working together

Hi

as title says I have problems with using SD card reader and ESP8266 together. Separately both work perfectly, but if I put them together, then I can't read from SD card and when ESP8266 initialization is finished the Arduino Uno is restarted (I can see the serial print that is on start of the setup function).

Did anyone successfully used them together on Arduino Uno?

After a whole day of researching, I come to conclusion that this two things together use up to much ram.
I found freeRam() function on the internet and when both, sd card and esp are used, theres only 157 bytes free.
And when ESP is initialized, it uses the rest of the sram and then it crashes.
And I need to verify this, so do you guys agree that this is the reason why program crashes?

I also tried using different library for ESP8266 but the result was the same.
Also I replace ESP8266 with GPS modul that also uses a SoftwareSerial and it worked fine with sd card, and free ram in that case was around 500 bytes.
Also I'm using external power supply, so the current is not a problem, like it was suggested hear: ESP8266 and SD card reader problem - Project Guidance - Arduino Forum

If I comment one if the readWiFiSettings(); or setupWiFi(); functions, then the one that is not commented works fine.
Here is my code:

#include <Arduino.h>
#include <SoftwareSerial.h>
#include <SPI.h>
#include <SD.h>
#include <WiFiEsp.h>

#define DEBUG_MODE true

#define FILE_NAME_WIFI_SETTINGS "wifi.txt"
#define WIFI_BAUNDRATE 9600
#define PIN_WIFI_TX 5
#define PIN_WIFI_RX 6
#define PIN_SDCARD_CS 10

SoftwareSerial ssWiFi(PIN_WIFI_RX, PIN_WIFI_TX);
WiFiEspClient wifiClient;
char ssid[] = "TheForce";
char pass[] = "TheForcePassword";
char server[] = "google.com";
bool gotResponseFromServer = false;

void readWiFiSettings() {
  String wifiSSID, wifiPass;
  #if DEBUG_MODE
    Serial.println("Reading WiFi settings file.");
  #endif
  File myFile = SD.open(FILE_NAME_WIFI_SETTINGS);
  if (myFile) {
    while(myFile.available()) {
      //Serial.write(myFile.read());
      wifiSSID = myFile.readStringUntil('\n');
      wifiPass = myFile.readStringUntil('\n');
    }
    myFile.close();

    #if DEBUG_MODE
      Serial.print("WiFi SSID: ");
      Serial.println(wifiSSID);
      Serial.print("WiFi Pass: ");
      Serial.println(wifiPass);
    #endif
  } else {
    #if DEBUG_MODE
      Serial.println("Error opening file with WiFi settings!");
    #endif
  }
}

void setupWiFi() {
  #if DEBUG_MODE
    Serial.println("setupWiFi called");
  #endif

  ssWiFi.begin(WIFI_BAUNDRATE);
  delay(500);
  ssWiFi.listen();
  delay(500);

  // Initialize WiFi module.
  WiFi.init(&ssWiFi);
  // Check for the presence of the WiFi module.
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi module not found!");
    return;
  }

  // Attempt to connect to WiFi network.
  while(WiFi.status() != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WiFi network.
    WiFi.begin(ssid, pass);
  }

  if(WiFi.status() != WL_CONNECTED) {
    Serial.println("Could NOT connect to wifi network.");
    return;
  }
  Serial.println("Connected to the wifi network.");

  gotResponseFromServer = false;
  Serial.println();
  Serial.println("Starting connection to server...");
  // if you get a connection, report back via serial
  if (wifiClient.connect(server, 80)) {
    Serial.println("Connected to server");
    // Make a HTTP request
    wifiClient.println("GET / HTTP/1.1");
    wifiClient.println("Host: www.google.com");
    wifiClient.println("Connection: close");
    wifiClient.println();
  } else {
    Serial.println("Could NOT connect to server.");
  }
}

int freeRam()
{
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

void setup()
{
  Serial.begin(115200);

  #if DEBUG_MODE
    Serial.println("-------------------------------");
    Serial.println("Device turned on.");
  #endif

  Serial.print("Free sram: ");
  Serial.println(freeRam());

  if (!SD.begin(PIN_SDCARD_CS)) {
    #if DEBUG_MODE
      Serial.println("Initialization of SD card failed!");
      Serial.println("Stopping the program!");
    #endif
    while(1);
  }

  readWiFiSettings();
  //setupWiFi();
}

void loop()
{
  // If there are incoming bytes available from the server, read them and print them.
  while (wifiClient.available()) {
    char c = wifiClient.read();
    Serial.write(c);
  }
  // if the server's disconnected, stop the wifiClient
  if (!gotResponseFromServer && !wifiClient.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    wifiClient.stop();
    gotResponseFromServer = true;
  }
}