Programmers Want an Easy Way to Clear Messages Without Slowing Down
This could make your apps faster and less buggy.
A programmer is asking for feedback on a problem and proposal in performance-sensitive C++ code, such as controllers. They say they have to compromise between memory efficiency and semantics/correctness when publishing: they want code to behave as if creating a new message from scratch each time without actually doing that.
Right now, they say they either store/reuse a message, like the realtime publisher does, or create a new message each time. Creating a new one gets rid of memory, especially heap memory allocated by the lists in the message, while reusing one risks leaving fields or subfields with stale data from the previous iteration.
They ask for tips and propose that C++ message code generation could generate a clear method that clears all lists in the message and recursively for sub messages, plus maybe reset other types to their default values. They ask for thoughts.
- Reusing messages saves memory but can cause bugs from leftover data.
- A 'clear' method would reset messages to default values automatically.
- This could make software faster and more reliable for everyone.
Why It Matters
Faster, more reliable software means fewer crashes and smoother experiences for users.