I am trying to implement a cache-like collection of objects. The purpose is to have fast access to these objects through locality in memory since I\'ll likely be reading multip
No, you can't guarantee this locality of reference.
By allocating a byte array, or using a mapped byte buffer from the nio
packages, you could get a chunk of contiguous memory, from which you can decode the data you want (effectively deserializing the objects of interest from this chunk of memory). However, if you repeatedly access the same objects, the deserialization overhead would likely defeat the purpose.