Пример #1
0
        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;
        }
Пример #2
0
        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();
            });
        }
Пример #3
0
        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();
            });
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
 public void Dispose()
 {
     _lazyTransactionPager?.Dispose();
 }
Пример #6
0
 public void Dispose()
 {
     _scratchPager.Dispose();
 }
Пример #7
0
 public void Dispose()
 {
     _scratchPager.PagerState.DiscardOnTxCopy = true;
     _scratchPager.Dispose();
 }