esp8266 / esp8266/Arduino

Decreased free heap in v3.0.0

Open
#8,124 14 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

### Basic Infos

- [x] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [x] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [ ] I have tested that the issue is present in current master branch (aka latest git). <== I don't know how with PlatformIO?
- [x] I have searched the issue tracker for a similar issue.
- [ ] If there is a stack dump, I have decoded it.
- [x] I have filled out all fields below.

#### Platform

- Hardware: [ESP-12]
- Core Version: 3.0.0
- Development Env: [Platformio]
- Operating System: [Windows]

### Settings in IDE

- Module: [Nodemcu]
- Flash Size: [4MB]
- Reset Method: [nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz]
- Upload Using: [SERIAL]
- Upload Speed: [115200] (serial upload only)

### Problem Description

I suddenly found my free heap reduced significantly.

I did some testing for this and I got the following numbers. Test A was a minimal sketch without the ESPAsyncWebServer, and test B was using the full code below.

Test A - Arduino 2.7.4: 51752 kB free heap
Test A - Arduino 3.0.0: 50784 kB free heap

Test B - Arduino 2.7.4: 43496 kB free heap
Test B - Arduino 3.0.0: 38480 kB free heap

This means that on the sketch with ESP Async WebServer I have lost 5Kb of heap without any changes to the code, except for the update to 3.0.0. The Async WebServer PlatformIO package has not been updated in over a year, so the codebase for that is the same. This is also why I opened the issue here, and not there.

Which changes in 3.0.0 could have caused this increased memory usage, and would there be ways to mitigate this?

### [MCVE](https://stackoverflow.com/help/mcve) Sketch

```cpp

#include
#include //this line was removed for test A

void setup()
{
Serial.begin(9600);
AsyncWebServer server = AsyncWebServer(80); //this line was removed for test A
AsyncWebSocket ws = AsyncWebSocket("/ws"); //this line was removed for test A
}

void loop()
{
Serial.println(ESP.getFreeHeap());
delay(5000);
}

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.