voltdb off heap内存的一点代码

ElasticHashinator.java, 


m_tokens = Bits.unsafe.allocateMemory(bytes);
m_cleaner = Cleaner.create(this, new Deallocator(m_tokens, bytes));
private static class Deallocator implements Runnable {
    private long address;
    private int size;
    public Deallocator(long address, int size) {
        this.address = address;
        this.size = size;
    }

    @Override
    public void run() {
        if (address == 0) {
            return;
        }
        Bits.unsafe.freeMemory(address);
        address = 0;
        m_allocatedHashinatorBytes.addAndGet(-size);
    }
}

 


http://www.docjar.com/docs/api/sun/misc/Unsafe.html
http://www.docjar.com/docs/api/sun/misc/Cleaner.html
posted @ 2017-08-24 17:36  brayden  阅读(194)  评论(0编辑  收藏  举报