Author Topic: Measures to prevent "Low memory available, stability problems may occur."  (Read 3778 times)

djflix

  • Newbie
  • *
  • Posts: 24
As some of you might have seen, I'm building a power consumption (KWh) meter using the Oak. I'm currently at a point where I have the following libraries included, and the Arduino IDE warns me about stuffing too much in Global Variables:

Code: [Select]
#include <Wire.h>
#include <EEPROM.h>

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPClient.h>

Resulting in the following message:
Code: [Select]
Low memory available, stability problems may occur.
My project gives me the following output:
Code: [Select]
Sketch uses 368,211 bytes (35%) of program storage space. Maximum is 1,040,368 bytes.
Global variables use 63,945 bytes (78%) of dynamic memory, leaving 17,975 bytes for local variables. Maximum is 81,920 bytes.

While a bare sketch yields the following:
Code: [Select]
Sketch uses 259,578 bytes (24%) of program storage space. Maximum is 1,040,368 bytes.
Global variables use 51,056 bytes (62%) of dynamic memory, leaving 30,864 bytes for local variables. Maximum is 81,920 bytes

Considering the fact that there's a web server, code for handling button input, code for handling the SSD1306 OLED display, and a web client that retrieves the actual current time I think my memory usage is reasonable, but I'd like to cut it down.

Things I've tried:
- Placing F() around strings
- Changing char[] into const char[] PROGMEMs

What could be the next steps to reduce Global Var usage? Should I dig in to OakSystem myself? Or is there anything else I could try? (for example replacing the ESP8266 libraries for HTTP Server/Client with something else?) All suggestions are welcome. If you want to check out the code, check out the add-webserver branch here: https://github.com/DJFliX/OakPowerBoard

Thanks!