@Override
	protected ByteBuffer onAllocate(int size, AtomicBoolean cache) 
	{
		if (size < minSize || size > maxSize) {
			return ByteBuffer.allocate(size);
		}
		
		ByteBuffer buffer = null;
		ByteBufferStack stack = map.get(size);
		if (stack != null) {
			buffer = stack.pop();
		}
		if (buffer == null) {
			try {
				buffer = ByteBuffer.allocateDirect(size);
			}
			catch (OutOfMemoryError e) {
				System.err.format("Cannot allocate a ByteBuffer of size %d; out of memory.\n", size);
				return null;
			}
		}
		else {
			cache.set(true);
		}
		return buffer;
	}