Fix memory consumption/fragmentation issues and - #58
Open
jamesinc wants to merge 1 commit into
Open
Conversation
timclarke07
added a commit
to timclarke07/ESP32-Plane-Radar
that referenced
this pull request
Aug 12, 2026
Adapted from upstream PR MatixYo#58 (memory). Reusing WiFiClientSecure/HTTPClient across fetches avoids heap fragmentation from allocating and freeing a new TLS context every ~3 s, which otherwise surfaces as SSL memory errors after long uptime. Bitmap (non-smooth) cardinals/tags fall back to 9pt. Default preset is now 15 km.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I had a lot of trouble with JSON payload parsing randomly losing bytes, and after the esp32 has been running for some time, was also seeing errors relating to memory allocation for the SSL socket.
After some digging I have made a few changes. Most controversially, the config portal will now despawn after 5 minutes without a setting being changed. I figure I don't really need it much but can always reboot to launch it.
The adsb_client.cpp changes are all for memory optimisation. The client objects are now reused, and
PollingStreamreplacespayload.concat()so data is now streamed in directly, avoiding an intermediate string buffer, which is what was causing the random missing API response bytes.PollingStreamuses a chunked buffer so thatpollNetwork()can be called at an appropriate rate.I also asked Claude for its opinions on the ADSB client and it suggested adding a deserialisation filter that eliminates all the extraneous keys from the JSON payloads, that seems to work well so I've included it also.
Finally, I tweaked the font sizes for when font smoothing is disabled as some of them were huge.
If there is interest in merging any of this work but you want to de-scope any of it let me know and I will amend the PR accordingly.