Skip to content

DNSServer memory leak #6663

@alex-code

Description

@alex-code

Board

DFRobot FireBeetle2

Device Description

None

Hardware Configuration

None

Version

v2.0.2

IDE Name

PlateformIO

Operating System

Win11

Flash frequency

80

PSRAM enabled

no

Upload speed

115200

Description

A project I'm working on uses DNSServer on demand and I noticed a memory leak.

Memory is allocated in the DNSServer class constructor but there's no destructor to free it.

https://github.com/espressif/arduino-esp32/blob/master/libraries/DNSServer/src/DNSServer.cpp#L16
https://github.com/espressif/arduino-esp32/blob/master/libraries/DNSServer/src/DNSServer.cpp#L17

Sketch

None

Debug Message

None

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Activity

mrengineer7777

mrengineer7777 commented on Apr 29, 2022

@mrengineer7777
Collaborator

That's true. Several libraries have that issue. However since DNSServer is generally only called once and then remains in memory, it is basically a global allocation. If it really bothers you, write the destructor and submit a PR.

self-assigned this
on Apr 29, 2022
SuGlider

SuGlider commented on Apr 29, 2022

@SuGlider
Collaborator

That's true. Several libraries have that issue. However since DNSServer is generally only called once and then remains in memory, it is basically a global allocation. If it really bothers you, write the destructor and submit a PR.

I think it would be good to review the whole code and fix these similar issues.
Thanks @alex-code for reporting!

alex-code

alex-code commented on Apr 29, 2022

@alex-code
Author

That's true. Several libraries have that issue. However since DNSServer is generally only called once and then remains in memory, it is basically a global allocation. If it really bothers you, write the destructor and submit a PR.

It may typically be used globally but if it allocates memory it should really free it too.

I don't mind doing a PR for allocations that need freeing if it'll be useful.

added this to the 2.0.4 milestone on May 4, 2022
SuGlider

SuGlider commented on May 6, 2022

@SuGlider
Collaborator

@alex-code - PR #6707 shall fixes it.
Please let me know if you can confirm that it solves this issue.

alex-code

alex-code commented on May 7, 2022

@alex-code
Author

@alex-code - PR #6707 shall fixes it. Please let me know if you can confirm that it solves this issue.

Looks good to me, testing again with the changes the free memory reported before construction is the same after destroying 👍

SuGlider

SuGlider commented on May 7, 2022

@SuGlider
Collaborator

@alex-code - Thanks for testing and confirming the resolution of this issue.

Repository owner moved this from In Review to Done in Arduino ESP32 Core Project Roadmapon May 9, 2022
added
Status: SolvedThe issue has been resolved and requires no further action.
and removed on May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Relationships

None yet

    Development

    Participants

    @alex-code@mrengineer7777@SuGlider@VojtechBartoska

    Issue actions

      DNSServer memory leak · Issue #6663 · espressif/arduino-esp32