Learning MIO: Zero allocations at runtime

#1

Hi! I started learning MIO. When I was skimming through the readme file I noticed “Zero allocations at runtime”. What does it even mean?

#2

Mio promises to not do memory allocations (on the heap) during runtime by itself[*1].
E.g. it requires Tokens to be passed around and used to identify which event happened. It’s up to higher-level libraries or your application code to take action on these events/tokens.

*1: After looking through the code just briefly, this is not entirely true, at least the epoll wrapper uses an internal Vec to store events.

1 Like
#3

That allocation happens at initialize/setup time and doesn’t reallocate at running time. This is what we call usually “Zero allocation at runtime”, allocate a few at startup and just use it over and over.

1 Like
#4

Ah, fair enough, thanks for the clarification. Slightly different views on what “runtime” is then.

3 Likes