1. 程式人生 > >voltdb off heap內存的一點代碼

voltdb off heap內存的一點代碼

dealloc col allocated ner ble eal static 內存 bits

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

voltdb off heap內存的一點代碼