private void AllocationSampleReadCallback(AllocationSample arg)
 {
     foreach (var allocation in arg.Allocations)
     {
         RecordAllocation(arg.Ticks, allocation);
         RecordSnapshot(arg.Ticks, allocation);
     }
 }
예제 #2
0
        private AllocationSample ParseSamMem(Match match)
        {
            var memSample = new AllocationSample(match.Groups[3].HexToUInt64(), match.Groups[4].ToUInt64());

            foreach (Match allocMatch in AllocInfo.Matches(match.Groups[5].Value))
            {
                memSample.Allocations.Add(new AllocationSampleInfo(
                                              allocMatch.Groups[1].HexToUInt64(),
                                              allocMatch.Groups[2].ToUInt64(),
                                              allocMatch.Groups[3].ToUInt64(),
                                              allocMatch.Groups[4].Value.Length > 0
                        ? allocMatch.Groups[5].Value.HexToUInt64()
                        : (ulong?)null));
            }

            return(memSample);
        }
        private void AllocationSampleReadCallback(AllocationSample arg)
        {
            var thread = Threads[arg.InternalId];

            var result = $"sam mem 0x{arg.InternalId:X8} {arg.Ticks}";

            foreach (var allocation in arg.Allocations)
            {
                result += $" 0x{allocation.ClassIntId:X}:{allocation.AllocationCount}:{allocation.MemorySize}";

                var function = GetFunction(thread.TopFunctionCall.FunctionIntId);
                if (function != null)
                {
                    result += $":0x{GetSourceLineNumberFromPc(function, allocation.Ip):X}";
                }
            }

            Output.WriteLine(result);
        }
예제 #4
0
        private void AllocationSampleReadCallback(AllocationSample arg)
        {
            if (_profilingPaused)
            {
                return;
            }

            var thread    = _stackByThread[arg.InternalId];
            var allocated = arg.Allocations.Aggregate <AllocationSampleInfo, ulong>(0, (current, item) => current + item.MemorySize);

            TotalAllocatedMemory += allocated;

            var sample = new Sample
            {
                ThreadIntId      = arg.InternalId,
                TimeMilliseconds = arg.Ticks,
                AllocatedMemory  = allocated
            };

            FillSampleStackItems(sample, thread.TopFunctionCall);
            FillSampleAllocationItems(sample, arg.Allocations);
            StoreSample(sample);
        }