private StreamWriter _sw = new StreamWriter(new MemoryStream()); //@"d:\temp\gc-log.txt"); public AutoMemoryManager(AutoMemoryManagementContext autoMemoryManagementContext, IMemoryManager underlying) { _sw.BaseStream.SetLength(0); _autoMemoryManagementContext = autoMemoryManagementContext; _underlying = underlying; _poolSize = _initialPoolSize; _pool = underlying.Alloc(_initialPoolSize).value; _defaultLayout = autoMemoryManagementContext.RuntimeGlobalAccessor.GetDefaultLayoutInfo(); _markBitFieldInfo = _defaultLayout.Fields[autoMemoryManagementContext.MarkBitFieldNumber]; _realBlockSizeFieldInfo = _defaultLayout.Fields[autoMemoryManagementContext.RealBlockSizeFieldNumber]; MMFreeBlockHeader *item = (MMFreeBlockHeader *)_pool; item->next = MMFreeBlockHeader.ZeroPtr; item->size = _poolSize - sizeof(MMFreeBlockHeader); _freeBlocks = item; _stats.currentAllocatedBlocksCount = 0; _stats.currentAllocatedBytes = 0; _stats.currentAllBlocksCount = 1; _stats.currentAvailableBytes = _poolSize; _stats.totalBlocksCreated = 1; _stats.totalBlocksMerged = 0; _stats.totalBlocksAllocated = 0; _stats.totalBlocksFreed = 0; }
public RuntimeGlobalAccessorImpl(IAutoMemoryManagerFabric gcFabric) { var stb = new NativeStructureBuilderImpl(this, "object"); _gcCtx = gcFabric.CreateManagerContext(this); if (_gcCtx.Integration != null) { _gcCtx.Integration.AugmentObjectLayout(stb); } stb.UseDefaultFieldAlignment = true; stb.FieldsAligmnent = null; stb.StructureAlignment = null; var typeIdFieldBuilder = stb.DefineField("typeId"); typeIdFieldBuilder.Size = IntPtr.Size; _objectLayout = stb.Complete(); _typeIdFieldInfo = _objectLayout.Fields.First(f => f.Number == typeIdFieldBuilder.Number); this.GenerateTypes(stb); _memoryManager = _gcCtx.CreateManager(_systemMemoryManager, this); }