public DataFile(string filePath, long initialSize, int growthIncrement) { try { bool isNew = !File.Exists(filePath); memoryMapper = new MemoryMapper(filePath, initialSize); mapping = MemoryMapping.Create(memoryMapper.fs, Constants.AllocationGranularity); dataFileHeaderPointer = (DataFileHeader *)mapping.GetBaseAddress(); this.growthIncrement = (growthIncrement + Constants.AllocationGranularityMask) / Constants.AllocationGranularity * Constants.AllocationGranularity; if (isNew) { InitializeHeader(); } else { ValidateHeader(); } } catch { Dispose(); throw; } }
public void Dispose() { if (IsDisposed) { return; } IsDisposed = true; List <Exception> exceptions = new List <Exception>(); if (mapping != null) { try { mapping.Release(); mapping = null; } catch (Exception ex) { exceptions.Add(ex); } } if (memoryMapper != null) { try { memoryMapper.Dispose(); memoryMapper = null; } catch (Exception ex) { exceptions.Add(ex); } } if (exceptions.Count > 0) { throw new AggregateException(exceptions); } }
internal MemoryMappingSession(MemoryMapper mapper) { this.mapper = mapper; mappings = new List <MemoryMapping>(); AddMapping(mapper.mapping); }