@Override
	public boolean free(ByteBuffer buffer)
	{
		boolean cached = false;

		// If caching this buffer will go over the maximum allowable cached
		// buffer memory then simply free the buffer and return the result.
		if (usedMemory.get() + buffer.capacity() > maxMemory.get()) {
			onFree(buffer);
		}
		// Try caching the buffer...
		else {
			cached = onCache(buffer);
			// If cached update used memory.
			if (cached) {
				usedMemory.addAndGet(buffer.capacity());
			}
			// Else free the buffer from memory.
			else {
				onFree(buffer);
			}
		}
		return cached;
	}