internal HeapStatistics GatherStatistics()
        {
            HeapStatistics stats = new HeapStatistics();

            Block block = m_FirstBlock;

            while (block != null)
            {
                if (block.allocated)
                {
                    stats.numAllocs++;
                    stats.allocatedSize += block.size;
                }
                else
                {
                    stats.freeSize += block.size;
                    stats.availableBlocksCount++;
                    stats.largestAvailableBlock = Math.Max(stats.largestAvailableBlock, block.size);
                }
                stats.blockCount++;
                block = block.next;
            }
            stats.totalSize     = totalSize;
            stats.highWatermark = m_HighWatermark;
            if (stats.freeSize > 0)
            {
                stats.fragmentation = (float)((double)(stats.freeSize - stats.largestAvailableBlock) / (double)stats.freeSize) * 100.0f;
            }

            return(stats);
        }
Пример #2
0
        internal HeapStatistics GatherStatistics()
        {
            HeapStatistics heapStatistics = default(HeapStatistics);

            for (BestFitAllocator.Block block = this.m_FirstBlock; block != null; block = block.next)
            {
                bool allocated = block.allocated;
                if (allocated)
                {
                    heapStatistics.numAllocs     += 1u;
                    heapStatistics.allocatedSize += block.size;
                }
                else
                {
                    heapStatistics.freeSize             += block.size;
                    heapStatistics.availableBlocksCount += 1u;
                    heapStatistics.largestAvailableBlock = Math.Max(heapStatistics.largestAvailableBlock, block.size);
                }
                heapStatistics.blockCount += 1u;
            }
            heapStatistics.totalSize     = this.totalSize;
            heapStatistics.highWatermark = this.m_HighWatermark;
            bool flag = heapStatistics.freeSize > 0u;

            if (flag)
            {
                heapStatistics.fragmentation = (float)((heapStatistics.freeSize - heapStatistics.largestAvailableBlock) / heapStatistics.freeSize) * 100f;
            }
            return(heapStatistics);
        }
        public HeapStatistics GatherStatistics()
        {
            HeapStatistics stats = new HeapStatistics();

            stats.subAllocators = new HeapStatistics[] { m_Low.GatherStatistics(), m_High.GatherStatistics() };

            stats.largestAvailableBlock = uint.MaxValue;
            for (int i = 0; i < 2; i++)
            {
                stats.numAllocs            += stats.subAllocators[i].numAllocs;
                stats.totalSize             = Math.Max(stats.totalSize, stats.subAllocators[i].totalSize);
                stats.allocatedSize        += stats.subAllocators[i].allocatedSize;
                stats.largestAvailableBlock = Math.Min(stats.largestAvailableBlock, stats.subAllocators[i].largestAvailableBlock);
                stats.availableBlocksCount += stats.subAllocators[i].availableBlocksCount;
                stats.blockCount           += stats.subAllocators[i].blockCount;
                stats.highWatermark         = Math.Max(stats.highWatermark, stats.subAllocators[i].highWatermark);
                stats.fragmentation         = Math.Max(stats.fragmentation, stats.subAllocators[i].fragmentation);
            }
            stats.freeSize = stats.totalSize - stats.allocatedSize;
            return(stats);
        }
Пример #4
0
        public HeapStatistics GatherStatistics()
        {
            HeapStatistics heapStatistics = default(HeapStatistics);

            heapStatistics.subAllocators = new HeapStatistics[]
            {
                this.m_Low.GatherStatistics(),
                this.m_High.GatherStatistics()
            };
            heapStatistics.largestAvailableBlock = 4294967295u;
            for (int i = 0; i < 2; i++)
            {
                heapStatistics.numAllocs            += heapStatistics.subAllocators[i].numAllocs;
                heapStatistics.totalSize             = Math.Max(heapStatistics.totalSize, heapStatistics.subAllocators[i].totalSize);
                heapStatistics.allocatedSize        += heapStatistics.subAllocators[i].allocatedSize;
                heapStatistics.largestAvailableBlock = Math.Min(heapStatistics.largestAvailableBlock, heapStatistics.subAllocators[i].largestAvailableBlock);
                heapStatistics.availableBlocksCount += heapStatistics.subAllocators[i].availableBlocksCount;
                heapStatistics.blockCount           += heapStatistics.subAllocators[i].blockCount;
                heapStatistics.highWatermark         = Math.Max(heapStatistics.highWatermark, heapStatistics.subAllocators[i].highWatermark);
                heapStatistics.fragmentation         = Math.Max(heapStatistics.fragmentation, heapStatistics.subAllocators[i].fragmentation);
            }
            heapStatistics.freeSize = heapStatistics.totalSize - heapStatistics.allocatedSize;
            return(heapStatistics);
        }