Skip to content

DNSServer memory leak #6663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
alex-code opened this issue Apr 29, 2022 · 6 comments · Fixed by #6707
Closed
1 task done

DNSServer memory leak #6663

alex-code opened this issue Apr 29, 2022 · 6 comments · Fixed by #6707
Assignees
Milestone

Comments

@alex-code
Copy link

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.
@alex-code alex-code added the Status: Awaiting triage Issue is waiting for triage label Apr 29, 2022
@mrengineer7777
Copy link
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.

@SuGlider SuGlider added Type: Bug 🐛 All bugs Status: To be implemented Selected for Development Status: In Progress ⚠️ Issue is in progress and removed Status: Awaiting triage Issue is waiting for triage labels Apr 29, 2022
@SuGlider SuGlider self-assigned this Apr 29, 2022
@SuGlider
Copy link
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
Copy link
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.

@SuGlider
Copy link
Collaborator

SuGlider commented May 6, 2022

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

@SuGlider SuGlider moved this from Todo to In Review in Arduino ESP32 Core Project Roadmap May 6, 2022
@alex-code
Copy link
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
Copy link
Collaborator

SuGlider commented May 7, 2022

@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 Roadmap May 9, 2022
@VojtechBartoska VojtechBartoska added Status: Solved and removed Status: In Progress ⚠️ Issue is in progress labels May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

4 participants