You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When changing the settings from the GUI, a JSON document is dynamically allocated and the update() is called, where the Strings are set. The String class then allocates memory and copies the content to the memory from the heap, where it lives until it's changed again. But the JSON document (sometimes 2000 to 4000 bytes) is freed after the update.
A gap is left on the heap. It will be used later on, but the heap gets fragmented and the maximum allocatable heap shrinks.
The same happens when using persistancy, when initial data is loaded from FS..
My proposal is to use String.reserve() in the constructor for these members.
The size of the content is known in advance and can be well limited.
So the framework would leave the maximum heap possible to the user and not fragment the heap already at startup.
The text was updated successfully, but these errors were encountered:
In some services Strings are used as members.
They are initialized with empty buffer.
As an example WifiSettingsService.h.
When changing the settings from the GUI, a JSON document is dynamically allocated and the update() is called, where the Strings are set. The String class then allocates memory and copies the content to the memory from the heap, where it lives until it's changed again. But the JSON document (sometimes 2000 to 4000 bytes) is freed after the update.
A gap is left on the heap. It will be used later on, but the heap gets fragmented and the maximum allocatable heap shrinks.
The same happens when using persistancy, when initial data is loaded from FS..
My proposal is to use String.reserve() in the constructor for these members.
The size of the content is known in advance and can be well limited.
So the framework would leave the maximum heap possible to the user and not fragment the heap already at startup.
The text was updated successfully, but these errors were encountered: