public StorageEnvironment(StorageEnvironmentOptions options) { try { _log = LoggingSource.Instance.GetLogger <StorageEnvironment>(options.BasePath.FullPath); _options = options; _dataPager = options.DataPager; _freeSpaceHandling = new FreeSpaceHandling(); _headerAccessor = new HeaderAccessor(this); NumOfConcurrentSyncsPerPhysDrive = options.NumOfConcurrentSyncsPerPhysDrive; TimeToSyncAfterFlashInSec = options.TimeToSyncAfterFlashInSec; Debug.Assert(_dataPager.NumberOfAllocatedPages != 0); var remainingBits = _dataPager.NumberOfAllocatedPages % (8 * sizeof(long)); _validPages = new long[_dataPager.NumberOfAllocatedPages / (8 * sizeof(long)) + (remainingBits == 0 ? 0 : 1)]; _validPages[_validPages.Length - 1] |= unchecked (((long)ulong.MaxValue << (int)remainingBits)); _decompressionBuffers = new DecompressionBuffersPool(options); var isNew = _headerAccessor.Initialize(); _scratchBufferPool = new ScratchBufferPool(this); options.SetPosixOptions(); _journal = new WriteAheadJournal(this); if (isNew) { CreateNewDatabase(); } else // existing db, let us load it { LoadExistingDatabase(); } if (_options.ManualFlushing == false) { Task.Run(IdleFlushTimer); } } catch (Exception) { Dispose(); throw; } }