public void Dispose() { if (_disposed) { return; } _disposed = true; // we cannot dispose the journal until we are done with all of the pending writes if (_lazyTransactionBuffer != null) { _lazyTransactionBuffer.WriteBufferToFile(CurrentFile, null); _lazyTransactionBuffer.Dispose(); } _compressionPager.Dispose(); _lz4.Dispose(); _journalApplicator.Dispose(); if (_env.Options.OwnsPagers) { foreach (var logFile in _files) { logFile.Dispose(); } } else { foreach (var logFile in _files) { GC.SuppressFinalize(logFile); } } _files = ImmutableAppendOnlyList <JournalFile> .Empty; }
public ScratchBufferFile(AbstractPager scratchPager, int scratchNumber) { _scratchPager = scratchPager; _scratchNumber = scratchNumber; _allocatedPagesCount = 0; scratchPager.AllocatedInBytesFunc = () => AllocatedPagesCount * Constants.Storage.PageSize; _strongRefToAllocateInBytesFunc = new StrongReference <Func <long> > { Value = scratchPager.AllocatedInBytesFunc }; MemoryInformation.DirtyMemoryObjects.TryAdd(_strongRefToAllocateInBytesFunc); DebugInfo = new ScratchFileDebugInfo(this); _disposeOnceRunner = new DisposeOnce <SingleAttempt>(() => { _strongRefToAllocateInBytesFunc.Value = null; // remove ref (so if there's a left over refs in DirtyMemoryObjects but also function as _disposed = true for racy func invoke) MemoryInformation.DirtyMemoryObjects.TryRemove(_strongRefToAllocateInBytesFunc); _strongRefToAllocateInBytesFunc = null; _scratchPager.PagerState.DiscardOnTxCopy = true; _scratchPager.Dispose(); ClearDictionaries(); }); }
public ScratchBufferFile(AbstractPager scratchPager, int scratchNumber) { _scratchPager = scratchPager; _scratchNumber = scratchNumber; _allocatedPagesCount = 0; scratchPager.AllocatedInBytesFunc = () => AllocatedPagesCount * Constants.Storage.PageSize; _disposeOnceRunner = new DisposeOnce <SingleAttempt>(() => { _scratchPager.PagerState.DiscardOnTxCopy = true; _scratchPager.Dispose(); }); }
public void EnsureSize(int sizeInPages) { try { _lazyTransactionPager.EnsureContinuous(0, sizeInPages); } catch (InsufficientMemoryException) { // RavenDB-10830: failed to lock memory of temp buffers in encrypted db, let's create new file with initial size _lazyTransactionPager.Dispose(); _lazyTransactionPager = CreateBufferPager(); throw; } }
public void Dispose() { _lazyTransactionPager?.Dispose(); }
public void Dispose() { _scratchPager.Dispose(); }
public void Dispose() { _scratchPager.PagerState.DiscardOnTxCopy = true; _scratchPager.Dispose(); }