Skip to content

WiFiClientSecure connect memory leak #6257

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
serpetti opened this issue Feb 10, 2022 · 6 comments
Closed
1 task done

WiFiClientSecure connect memory leak #6257

serpetti opened this issue Feb 10, 2022 · 6 comments
Labels
Area: BT&Wifi BT & Wifi related issues Resolution: Expired More info wasn't provided

Comments

@serpetti
Copy link

Board

ESP32 Dev Module

Device Description

Every time I create a connection with WiFiClientSecure library I looseabout 100B of heap memory. Everything works, I connect(), I get data and I stop(). But the during next connect() I loose other memory.
Thanks

Hardware Configuration

esp32 dev kit 1 without PINs used

Version

latest master

IDE Name

Platform IO

Operating System

Windows 10

Flash frequency

40MHz

PSRAM enabled

no

Upload speed

115200

Description

Memory leak

Sketch

wifiClientSecure = new WiFiClientSecure();

        wifiClientSecure->setCACert(root_ca);

        if (!wifiClientSecure->connect("www.hamqsl.com", 443))
            Serial.println("Connection failed!");
        else
        {
            wifiClientSecure->println("GET https://www.hamqsl.com/solarxml.php HTTP/1.0");
            wifiClientSecure->println("Host: www.hamqsl.com");
            wifiClientSecure->println("Connection: close");
            wifiClientSecure->println();
            
            while (wifiClientSecure->connected())
            {
                String line = wifiClientSecure->readStringUntil('\n');
                if (line == "\r")
                {
                    break;
                }
            }            
            
            int len=0;
            while (wifiClientSecure->available())
            {
                char c = wifiClientSecure->read();  
                xmlRaw += c;     
                len++;
            }
            
            wifiClientSecure->flush();
            wifiClientSecure->stop();                 
    
            Serial.Println(xmlRaw);
        }   
        if(wifiClientSecure) delete wifiClientSecure;

Debug Message

No messages, only leak

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.
@serpetti serpetti added the Status: Awaiting triage Issue is waiting for triage label Feb 10, 2022
@mrengineer7777
Copy link
Collaborator

Possibly related to PR #6062?

@serpetti
Copy link
Author

Hi, thank you for your answer, I've read #6062, and I've tried to make only one persistent instance of WiFiClientSecure with only one CA certificate assignation, but seems that the leak appear on WiFiClientSecure connect() method.

@everslick
Copy link
Contributor

are you sure, your socket is not in FIN_WAIT state? does the memory return after some time? like 3 minutes?

@serpetti
Copy link
Author

Hi Everslick and thank you for your answer. I've to check for socket status, but I'm sure that memory remains occupied even after dozens of minutes

@VojtechBartoska
Copy link
Contributor

Hello, can you please retest this on v2.0.3-rc1? Is it still relevant?

@VojtechBartoska VojtechBartoska added Area: BT&Wifi BT & Wifi related issues Resolution: Awaiting response Waiting for response of author and removed Status: Awaiting triage Issue is waiting for triage labels Apr 11, 2022
@VojtechBartoska
Copy link
Contributor

I'm closing the issue as expired due to no answer.

If needed, please reopen it.

Thanks for understanding.

@VojtechBartoska VojtechBartoska added Resolution: Expired More info wasn't provided and removed Resolution: Awaiting response Waiting for response of author labels May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues Resolution: Expired More info wasn't provided
Projects
None yet
Development

No branches or pull requests

4 participants