I am casually reading about the Memory<T> class in C#, to figure out if I can use it to "format" memory allocations to be more contiguous. I don't know a lot of the finer details of computer memory, but I was thinking that if I can ensure that all of the UI classes in my game are allocated in a contiguous block of memory, the whole thing can be updated without cache misses, right?
Anyways, my question is, if I for instance have a UIManager class that instantiates, and keeps references to, ALL other UI classes in the game, can I simply use an instance of Memory<UIManager> to allocate all of the UI contiguously? Or would I need a bunch of different Memory<T> instances? And in the latter case, do I have any control over whether it will be allocated contiguously or not? I've tried googling and reading documentation, but I can't figure it out.
I am using the Monogame framework for my game btw.