@Override
	protected long onFill() 
	{
		// This algorithm will ensure each stack of buffers is taking up the
		// same amount of memory. So a stack for 128 will have 2 buffers
		// for every buffer on a stack for 256. I figure even distribution of
		// the current memory usage is a fair algorithm to fill the cache.
		
		long memory = 0;
		// How much memory is available...
		long available = getAvailable();
		
		// Caculate how much memory it would cost to add a buffer to each of the
		// stacks in the pool.
		long poolCount = (maxPower - minPower + 1);
		int maxPool = (1 << maxPower);
		long generationSize = maxPool * poolCount;
		
		// Calculate how many generations we can add to the cache
		int generations = (int)Math.floor(available / generationSize);
		if (generations == 0) {
			return 0;
		}
		
		// Add these buffers to the stacks
		ByteBuffer buffer = null;
		for (int p = minPower; p <= maxPower; p++) 
		{
			int index = p - minPower;
			int bufferCount = generations << (p - maxPower); 
			
			// Add a stack in for each generation.
			for (int c = 0; c < bufferCount; c++) 
			{
				buffer = ByteBuffer.allocateDirect(1 << p);
				// Ensure the buffer was allocated.
				if (buffer != null) {
					memory += buffer.capacity();
					pool[index].push(buffer);	
				}
				// We couldn't allocate any more buffers?
				else {
					return memory;
				}
			}
		}
		
		return memory;
	}