Skip to content

Free String memory on assign of "" or clear() #8486

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
wants to merge 1 commit into from

Conversation

earlephilhower
Copy link
Collaborator

Fixes #8485

Whenever the empty C string is assigned or the .clear() method
called, free any heap allocated with the String.

Fixes esp8266#8485

Whenever the empty C string is assigned or the .clear() method
called, free any heap allocated with the String.
Copy link

@erkr erkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider this not desirable. Use case for reserve() is to avoid memory fragmentation. To reuse such a String , cleaning without releasing the reserved memory is required.
Strings can be freed this way already:

String reserved=String():

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

String clear() does not free memory, only set length(0)
2 participants