Skip to content
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

EthernetClient memory consumption #75

Closed
jeremyB01 opened this issue Nov 5, 2023 · 2 comments · Fixed by #76
Closed

EthernetClient memory consumption #75

jeremyB01 opened this issue Nov 5, 2023 · 2 comments · Fixed by #76
Labels
bug 🐛 Something isn't working
Milestone

Comments

@jeremyB01
Copy link
Contributor

In the EthernetClient::connect(IPAddress ip, uint16_t port) function there is memory allocated for the _tcp_client variable. In the EthernetClient::stop() the allocated memory is not freed up. Am I missing some part where allocated memory is freed up after usage or does this have an other specific reason?
I stumbled over that issue by trying to keep me footprint as small as possible and only generating a EthernetClient object if needed and closing it afterwards.

@fpistm fpistm added the bug label Nov 6, 2023
@fpistm
Copy link
Member

fpistm commented Nov 6, 2023

Hi @jeremyB01
You probably right.

void EthernetClient::stop()
{
  if (_tcp_client == NULL) {
    return;
  }

  // close tcp connection if not closed yet
  if (status() != TCP_CLOSING) {
    tcp_connection_close(_tcp_client->pcb, _tcp_client);
  }
+ mem_free(_tcp_client);
}

Could you submit a PR and test?
Thanks in advance.

@jeremyB01
Copy link
Contributor Author

Created PR. The bug seems to be resolved. Thanks a lot.

@fpistm fpistm added this to the 1.3.1 milestone Nov 7, 2023
@fpistm fpistm linked a pull request Nov 7, 2023 that will close this issue
@fpistm fpistm closed this as completed Nov 7, 2023
@fpistm fpistm added the bug 🐛 Something isn't working label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

2 participants