@Override
	protected void ensureCapacity(int incCap) {
		if(incCap < remained()) { return; }
		
		int newCapacity = 0;
		if(2*incCap <= capacity) {
			newCapacity = capacity * 3 / 2 + 1;
		}else {
			newCapacity = capacity * 2;
		}
		
		MemoryBlock newBlock = MemoryBlock.allocate(newCapacity);
		if(size > 0) {
			long oldAddress = block.address;
			long newAddress = newBlock.address;
			if(putIndex > takeIndex) {
				copyMemory(oldAddress, takeIndex, newAddress, 0, size);
			}else {
				int len = capacity - takeIndex;
				copyMemory(oldAddress, takeIndex, newAddress, 0, len);
				if(size > len) {
					copyMemory(oldAddress, 0, newAddress, len, putIndex);
				}
			}
		}
		
		MemoryBlock.deallocate(block);	// clean old memory
		block = newBlock;
		capacity = newCapacity;
		takeIndex = 0;
		putIndex = size;
	}