My goal is to ensure that an array allocated in java is allocated across contiguous physical memory. The issue that I've run into is that the pages an array is allocated across tend not to be contiguous in physical memory, unless I allocate a really large array.
My questions are:
- Why does a really large array ensure pages which are contiguous in physical memory?
- Is there any way to ensure an array is allocated across physical memory, that doesn't involve making the array really large?
- How can I tell what page or physical address a Java object/array exists in, without measuring cache hits/cache misses?
I'm not looking for answers asking why I am doing this in java. I understand that C would "solve my problem", and that I'm going against the fundamental nature of java. Never-the-less I have a good reason for doing this.
The answers need not be guaranteed to work all the time. I am looking for answers that work most of the time. Extra points for creative, out-of-the-box answers that no reasonable Java programmer would ever write. It's OK to be platform specific(x86 32-bit 64-bit).