in directmemory-cache/src/main/java/org/apache/directmemory/memory/MemoryManagerServiceImpl.java [212:251]
public <T extends V> Pointer<V> allocate( final Class<T> type, final int size, final long expiresIn,
final long expires )
{
Pointer<V> p = null;
Allocator allocator = null;
int allocationNumber = 0;
do
{
allocationNumber++;
allocator = allocationPolicy.getActiveAllocator( allocator, allocationNumber );
if ( allocator == null )
{
if ( returnsNullWhenFull() )
{
return null;
}
else
{
throw new BufferOverflowException();
}
}
final MemoryBuffer buffer = allocator.allocate( size );
if ( buffer == null )
{
continue;
}
p = instanciatePointer( buffer, allocator.getNumber(), expiresIn, NEVER_EXPIRES );
used.addAndGet( size );
}
while ( p == null );
p.setClazz( type );
return p;
}