private synchronized void release(ByteBuffer buffer) {
        if (buffer != null && buffer.isDirect()) {
            for (int i = buffer.position(); i < buffer.limit(); i++) {
                buffer.put((byte) 0);
            }
            buffer.clear();

            try {
                while (true) {
                    final Key key = new Key(buffer.capacity(), System.nanoTime());
                    if (!bufferMap.containsKey(key)) {
                        bufferMap.put(key, buffer);
                        return;
                    }
                    // Buffers are indexed by (capacity, time).
                    // If our key is not unique on the first try, we try again, since the
                    // time will be different.  Since we use nanoseconds, it's pretty
                    // unlikely that we'll loop even once, unless the system clock has a
                    // poor granularity.
                }
            } catch (Exception e) {
                // if a buffer is not released back to the pool then it is not the end of the world
                // is we can just create more as required.
                throw new RuntimeException("Error releasing buffer back to the pool", e);
            }
        }
//        if (LOGGER.isDebugEnabled()) {
//            releaseCount.incrementAndGet();
//        }
    }
An unbounded self-populating pool of directly allocated ByteBuffers.
When using one of the methods to get/use a buffer from the pool the
smallest available buffer that is greater than or equal to the required
capacity will be provided. All buffers will be cleared on return to
the pool.
<p>
As this pool is un-bounded it could grow very large under high contention
stroom-bytebuffer/src/main/java/stroom/bytebuffer/ByteBufferPoolImpl3.java