esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
15.98k stars 13.34k forks source link

'Reallocating large String(... -> ...)' warning when using WebServer #8872

Open hmueller01 opened 1 year ago

hmueller01 commented 1 year ago

Hi,

since PR #8821 I get this output from ESP8266WebServer:

[String] 'Content-Ty ... ires: -1
': Reallocating large String(140 -> 162 bytes)

It's from this line https://github.com/esp8266/Arduino/blob/be02af0504869e2bf119a013fe8fd6cf5ed8e411/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h#L433 if sendHeader() is used more than once. Like here: https://github.com/khoih-prog/ESP_WiFiManager_Lite/blob/085afdbd7ccfb7e46b1ed9f1cf5c50be29cc3223/src/ESP_WiFiManager_Lite.h#L2771

Is there something we can do against it?

d-a-v commented 1 year ago

Thanks for having revealed an internal misuse of strings. Fixing this is on us.

d-a-v commented 1 year ago

If you are using the git version of this core, can you try with #8873 ?

(or the unofficial "nightly" alpha release)

hmueller01 commented 1 year ago

As written in #8873 the change in ESP8266WebServer looks good to me.

There is similar issue in ESP8266HTTPClient https://github.com/esp8266/Arduino/blob/6ad9bf3b07ecbe8dd34623c8f81db3b7614cffbf/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp#L820 if you add multiple headers ...

mathertel commented 1 year ago

The output appears also in the published version 3.1.2 when DEBUG_ESP_PORT is enabled even when Debug Level == none.

Example:

[String] 'Content-Ty ... rigin: *
': Reallocating large String(159 -> 183 bytes)
[String] 'Content-Ty ... ep-alive
': Reallocating large String(183 -> 209 bytes)