If the messages had to be added and removed from an array when they are posted/handled, that’s adding a huge amount of overhead for every message. And the heavier the message load, the more the overhead grows, which could bring the system grinding to a halt if the queue gets too busy!
We opted for the pragmatic solution here: add no overhead to the runtime performance, at the expense of a few bytes of memory sometimes being harmlessly leaked on shutdown. If you’re posting huge message objects that would be harmful to leak, you could add your own layer that handles these through the same mechanism you suggest here.
