Пример #1
0
        public override void Free(OffHeapBlockAllocator_MemoryBlock block, MemoryAllocationTracker tracker)
        {
            if (_released || !IsCacheable(block.Size))
            {
                DoFree(block, tracker);
                return;
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.BlockingQueue<OffHeapBlockAllocator_MemoryBlock> cache = caches[log2floor(block.size)];
            BlockingQueue <OffHeapBlockAllocator_MemoryBlock> cache = _caches[log2floor(block.Size)];

            if (!cache.offer(block))
            {
                DoFree(block, tracker);
                return;
            }

            // it is possible that allocator is released just before we put the block into queue;
            // in such case case we need to free memory right away, since release() will never be called again
            if (_released && cache.remove(block))
            {
                DoFree(block, tracker);
                return;
            }

            tracker.Deallocated(block.UnalignedSize);
        }
Пример #2
0
 /// <summary>
 /// Free the memory that was allocated with <seealso cref="allocateMemory"/> and update memory allocation tracker accordingly.
 /// </summary>
 public static void Free(long pointer, long bytes, MemoryAllocationTracker allocationTracker)
 {
     Free(pointer, bytes);
     allocationTracker.Deallocated(bytes);
 }