| ▲ | gblargg 5 days ago | |
If you don't align the array to a 4K boundary in memory, fitting within a page isn't as big of an optimization win. | ||
| ▲ | account42 5 days ago | parent [-] | |
If the array is dynamically allocated on its own, you will likely get a whole page from any decent allocator. If it is statically allocated the compiler can at least theoretically optimize the alignment. If its allocated as part of a larger struct then yes its up to you. Even if it is not aligned, an unaligned 8K array would be spread to three pages which is still worse than two. | ||