munificent/game-programming-patterns

Why would we use a pre-allocated pool of list nodes for the observers?

JensB-tech opened this issue · 0 comments

He says earlier (on p.46) in the observer chapter that you would usually use a dynamically sized collection for the observer pointers instead of a "dumb array", so that you don't have to use a compile-time constant for the max amount of observers a subject can have watching it.
But then later (on p.53), he says that in order to avoid dynamically allocating the list nodes you should use a pre-allocated pool of list nodes. This confuses me, aren't we back to the same problem we had earlier when we had a fixed array of observer pointers? With a pre-allocated pool, we have to decide on a maximum number of observers for not just one subject, but for the whole program. How is that sustainable?