Search in sources :

Example 1 with CharArray

use of io.mycat.memory.unsafe.array.CharArray in project Mycat-Server by MyCATApache.

the class MemoryConsumer method allocateCharArray.

public CharArray allocateCharArray(long size) {
    long required = size * 2L;
    MemoryBlock page = dataNodeMemoryManager.allocatePage(required, this);
    if (page == null || page.size() < required) {
        long got = 0;
        if (page != null) {
            got = page.size();
            dataNodeMemoryManager.freePage(page, this);
        }
        dataNodeMemoryManager.showMemoryUsage();
        throw new OutOfMemoryError("Unable to acquire " + required + " bytes of memory, got " + got);
    }
    used += required;
    return new CharArray(page, this);
}
Also used : MemoryBlock(io.mycat.memory.unsafe.memory.MemoryBlock) CharArray(io.mycat.memory.unsafe.array.CharArray)

Aggregations

CharArray (io.mycat.memory.unsafe.array.CharArray)1 MemoryBlock (io.mycat.memory.unsafe.memory.MemoryBlock)1