-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Move some constant arrays from data to text section #9187
Conversation
_default_tunes was marked as 'const char *' array, which means the data of the array was not actually const and thus landed in the data section (so in RAM instead of FLASH). The size of the array is 64 bytes.
_uorb_topics_list was marked as 'const char *' array, which means the data of the array was not actually const and thus landed in the data section (so in RAM instead of FLASH). The size of the array is 436 bytes.
@bkueng Awesome, thank you very much. How did you find it? :) |
@@ -56,7 +56,7 @@ msgs_count_all = len(msg_names_all) | |||
@[end for] | |||
|
|||
const size_t _uorb_topics_count = @(msgs_count_all); | |||
const struct orb_metadata* _uorb_topics_list[_uorb_topics_count] = { | |||
const constexpr struct orb_metadata* const _uorb_topics_list[_uorb_topics_count] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't constexpr
alone instead of const constexpr
suffice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case yes. But more is more :D
I was looking at what needs how much space in the different ELF sections. For example you can look at the largest consumers in the data section with:
|
Thanks, I did not know that |
2 Arrays with constant data in uORB and the tunes library were marked as 'const T *' array, which means the data of the array was not actually const and thus landed in the data section (so in RAM instead of FLASH).
Reduces RAM usage by ~500 bytes.
@potaito fyi