Skip to content

Conversation

@miceno
Copy link
Contributor

@miceno miceno commented Sep 21, 2025

This PR provides a heavy optimization over the strings used for text sensors, moving them from main SRAM memory to PROGMEM. In order to do it, it allocates static buffers for each text sensor up to the size of the max length of the strings. Although it requires static allocation, it prevents memory fragmentation and allow freeing a significant amount of memory.

In addition it includes an optimization on the management of the loop to show stats when the loop is taking too long.

And it also solves a recurrent "Too old data" issue by updating last_transmission when data is not available.

@syssi
Copy link
Collaborator

syssi commented Sep 21, 2025

Thanks for your contribution! Could you provide a comparison of the memory footprint (previous & now)? Thanks in advance!

@miceno
Copy link
Contributor Author

miceno commented Sep 21, 2025

I measure free heap and max heap block and here it is the result:

branch free heap max heap block
main 23832 19792
feat/reduce-memory 29344 24888

It is a memory reduction of over 5000 bytes.

@miceno
Copy link
Contributor Author

miceno commented Sep 25, 2025

Hold on, since I am experiencing memory leaks. It needs further research.

@miceno
Copy link
Contributor Author

miceno commented Oct 21, 2025

I forgot to update... it is was a false alarm, my devices was restarting from time to time and I thought it was the new code, but it wasn't that 👍

Please, review it and let me know if the PR requires some refinement.

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.

2 participants