Networkless ESP8266 Arduino

I’m developing small project which uses ESP8266, which doesn’t need any kind of networking (Wifi, TCP), but requires as much RAM as possible. I have noticed that network stuff (LWIP etc.) takes some RAM.
Is it possible to build Arduino ESP8266 project without networking libraries to save some RAM? Kind of: PIO_FRAMEWORK_ARDUINO_LWIP_NONE option.

How much more RAM exactly is needed for the application? If you have the newest Arduino IDE version and the newest ESP8266-core there is an option for the LWIP variant. This is also available in PIO (docs)

So as a first thing you could e.g. try

build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY

I didn’t see any easy way to completely disable the network stack. However, there are other SDKs which will allow you to do this and run on a very bare-bones environment. An example is cnlohr’s SDK “nosdk8266” which doesn’t have networking enabled. SDKnoWiFi is another possibility.

You could dive down the rabit hole and find out what static library using RAM using a linker map file and a tool like amap (build flags: -Wl,-Map,output.map), then try to remove it from the build process or substitute it with a dummy yourself.

Yes I’m using PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY but it gives very little improvement.

Other improvement is reducing stack:
-D CONT_STACKSIZE=1024

I have also analyzed briefly map file and memory is mostly consumed by: LWIP, sdk networking stuff and some by ARDUINO framework.
I know there are other SDKs, but I wasn’t aware of those noWiFi type. If there are no “out of the box” options in PlatformIO, than I will look into that.

Thank you for help.

I’ve noticed something strange.

WdevTimOffSet is int and should have size 4, but in my map file it is always almost 12kb which is a lot.

.bss .bss 3ffe9648 11744 wdev.o WdevTimOffSet

I have found someone else map file and it is indeed 4 bytes:

3fff0378 4 OBJECT GLOBAL DEFAULT 3 WdevTimOffSet
https://www.bountysource.com/issues/36305881-question-ways-to-decrease-the-initial-heap-consumption

What is going on here?