public AllocatedMemoryData GetMemory(int requestedSize)
        {
            var allocatedMemory = _arenaAllocator.Allocate(requestedSize);

            allocatedMemory.Parent = this;
            return(allocatedMemory);
        }
예제 #2
0
        private AllocatedMemoryData GetMemory(int requestedSize, bool longLived)
        {
            if (requestedSize <= 0)
            {
                throw new ArgumentException(nameof(requestedSize));
            }

            return(longLived
                ? _arenaAllocatorForLongLivedValues.Allocate(requestedSize)
                : _arenaAllocator.Allocate(requestedSize));
        }
예제 #3
0
        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);
        }