use of org.neo4j.configuration.GraphDatabaseSettings.TransactionStateMemoryAllocation in project neo4j by neo4j.
the class GlobalModule method createCollectionsFactorySupplier.
private static CollectionsFactorySupplier createCollectionsFactorySupplier(Config config, LifeSupport life) {
final TransactionStateMemoryAllocation allocation = config.get(tx_state_memory_allocation);
switch(allocation) {
case ON_HEAP:
return CollectionsFactorySupplier.ON_HEAP;
case OFF_HEAP:
final CachingOffHeapBlockAllocator allocator = new CachingOffHeapBlockAllocator(config.get(tx_state_off_heap_max_cacheable_block_size), config.get(tx_state_off_heap_block_cache_size));
final OffHeapBlockAllocator sharedBlockAllocator;
final long maxMemory = config.get(tx_state_max_off_heap_memory);
if (maxMemory > 0) {
sharedBlockAllocator = new CapacityLimitingBlockAllocatorDecorator(allocator, maxMemory);
} else {
sharedBlockAllocator = allocator;
}
life.add(onShutdown(sharedBlockAllocator::release));
return () -> new OffHeapCollectionsFactory(sharedBlockAllocator);
default:
throw new IllegalArgumentException("Unknown transaction state memory allocation value: " + allocation);
}
}
Aggregations