public AllocatedMemoryData GetMemory(int requestedSize) { var allocatedMemory = _arenaAllocator.Allocate(requestedSize); allocatedMemory.Parent = this; return(allocatedMemory); }
private AllocatedMemoryData GetMemory(int requestedSize, bool longLived) { if (requestedSize <= 0) { throw new ArgumentException(nameof(requestedSize)); } return(longLived ? _arenaAllocatorForLongLivedValues.Allocate(requestedSize) : _arenaAllocator.Allocate(requestedSize)); }
public AllocatedMemoryData GetLongLivedMemory(int requestedSize) { #if DEBUG || VALIDATE if (requestedSize <= 0) { throw new ArgumentException(nameof(requestedSize)); } #endif var allocatedMemory = _arenaAllocatorForLongLivedValues.Allocate(requestedSize); allocatedMemory.ContextGeneration = Generation; allocatedMemory.Parent = this; #if DEBUG allocatedMemory.IsLongLived = true; #endif return(allocatedMemory); }
public AllocatedMemoryData GetLongLivedMemory(int requestedSize) { //we should use JsonOperationContext in single thread if (_arenaAllocatorForLongLivedValues == null) { //_arenaAllocatorForLongLivedValues == null when the context is after Reset() but before Renew() ThrowAlreadyDisposedForLongLivedAllocator(); //make compiler happy, previous row will throw return(null); } var allocatedMemory = _arenaAllocatorForLongLivedValues.Allocate(requestedSize); allocatedMemory.Parent = this; return(allocatedMemory); }