Some things in AmigaOS need a few objects allocated before they can be used. For example, to use a device, it needs a port and IO Request allocated before it can even be opened. And in extra cases, if a device is used as a function base, more needs to be opened again, in order to access the library functions.
I don't like the idea of reopening and reclosing all these things only when they are requested. I'm just a bit pedantic about all the overhead involved. Plus, for years programs could use their own local variable space to store Exec structures, before this obsession with needing to allocate it came into being. On top of this, if you check what Workbench is doing, it constantly opens and closes the timer.device. Why doesn't it just open it open once and use it many?
So, I'm wondering about an alternate method to all this overhead. That is, pre-allocating all objects needed, then opening on demand, using them and then closing the resources when finished. In the case of a device, needing only to reopen and close it, if needed for one time use. In between, the memory would be reset to how it was at allocation. So a locally cached copy would be kept. The objects could be left as is, but I don't think re-using dirty objects is a good idea, without cleaning the laundry first, so to speak.
Does anyone use such a method to optimise code and reduce overhead? Or do you just re-allocate everything on demand and then free it? Which also complicates the code.