Skip to content

Instantly share code, notes, and snippets.

@coderplay
coderplay / TestMemoryAccessPatterns.java
Last active December 10, 2015 15:18
on-heap array vs off-heap array
public class TestMemoryAccessPatterns {
private static final int LONG_SIZE = 8;
private static final int PAGE_SIZE = 2 * 1024 * 1024;
private static final int ONE_GIG = 1024 * 1024 * 1024;
private static final int ARRAY_SIZE = (int) (ONE_GIG / LONG_SIZE);
private static final int WORDS_PER_PAGE = PAGE_SIZE / LONG_SIZE;
private static final int ARRAY_MASK = ARRAY_SIZE - 1;
private static final int PAGE_MASK = WORDS_PER_PAGE - 1;