[GH-ISSUE #619] Memory leak when reset()-ing DNS server #517

Closed
opened 2026-02-28 01:25:40 +03:00 by kerem · 2 comments
Owner

Originally created by @brianrho on GitHub (Jun 10, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/619

In startConfigPortal(), after the settings have been saved:

server.reset();
dnsServer.reset();

I assume the call to reset() relies on the existence of a destructor for the DNS server instance but there's none in the DNSServer class. The class makes use of the heap while processing requests and only frees all that memory when stop() is called, but that never happens in WiFiManager unless I've missed something.

Originally created by @brianrho on GitHub (Jun 10, 2018). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/619 In `startConfigPortal()`, after the settings have been saved: ``` server.reset(); dnsServer.reset(); ``` I assume the call to `reset()` relies on the existence of a destructor for the DNS server instance but there's none in the [DNSServer](https://github.com/esp8266/Arduino/blob/master/libraries/DNSServer/src/DNSServer.cpp) class. The class makes use of the heap while processing requests and only frees all that memory when `stop()` is called, but that never happens in `WiFiManager` unless I've missed something.
kerem 2026-02-28 01:25:40 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tablatronix commented on GitHub (Jun 10, 2018):

Hmm i made a note of this in dev branch because I suspected as much as these are smart pointers.

Would this be a bug in dnsserver? I mean it should clean itself up

<!-- gh-comment-id:396016558 --> @tablatronix commented on GitHub (Jun 10, 2018): Hmm i made a note of this in dev branch because I suspected as much as these are smart pointers. Would this be a bug in dnsserver? I mean it should clean itself up
Author
Owner

@brianrho commented on GitHub (Jun 10, 2018):

I looked at the code and it seems it's been years since anyone made any actual change to its header, which I take to mean that the class's current state and behaviour suits most people just fine and the lack of a destructor isn't a big deal; they just have to call stop() when they're done, which is common with Arduino libs anyways. All that's needed here is just a dnsServer->stop() before the reset(), I think.

<!-- gh-comment-id:396017005 --> @brianrho commented on GitHub (Jun 10, 2018): I looked at the code and it seems it's been years since anyone made any actual change to its header, which I take to mean that the class's current state and behaviour suits most people just fine and the lack of a destructor isn't a big deal; they just have to call `stop()` when they're done, which is common with Arduino libs anyways. All that's needed here is just a `dnsServer->stop()` before the `reset()`, I think.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#517
No description provided.