Inheritance: IDisposable
Beispiel #1
0
        protected HeapRecording(
            TaskScheduler scheduler,
            ActivityIndicator activities,
            string filename
            )
        {
            Scheduler  = scheduler;
            Activities = activities;

            DiffCache.ItemEvicted += DiffCache_ItemEvicted;

            if (filename.EndsWith(".heaprecording") || File.Exists(filename))
            {
                filename = Path.GetDirectoryName(filename);
            }

            if (!Directory.Exists(filename))
            {
                throw new Exception(String.Format("Recording not found: {0}", filename));
            }

            _Database = new DatabaseFile(Scheduler, filename); Futures.Add(Scheduler.Start(
                                                                               LoadRecordingMainTask(filename),
                                                                               TaskExecutionPolicy.RunAsBackgroundTask
                                                                               ));
        }
Beispiel #2
0
        public void OpenRecording(string filename)
        {
            if (!DatabaseFile.CheckTokenFileVersion(filename))
            {
                MessageBox.Show(this, "The recording you have selected was produced by a different version of Heap Profiler and cannot be opened.", "Error");
                return;
            }

            DisposeInstance();

            Instance = HeapRecording.FromRecording(
                Scheduler, Activities, filename
                );
            SubscribeToEvents(Instance);

            RefreshStatus();
            RefreshSnapshots();

            Scheduler.Start(
                RefreshFunctionNames(Instance), TaskExecutionPolicy.RunAsBackgroundTask
                );
        }
Beispiel #3
0
        protected HeapRecording(
            TaskScheduler scheduler,
            ActivityIndicator activities,
            string filename
        )
        {
            Scheduler = scheduler;
            Activities = activities;

            DiffCache.ItemEvicted += DiffCache_ItemEvicted;

            if (filename.EndsWith(".heaprecording") || File.Exists(filename))
                filename = Path.GetDirectoryName(filename);

            if (!Directory.Exists(filename))
                throw new Exception(String.Format("Recording not found: {0}", filename));

            _Database = new DatabaseFile(Scheduler, filename); Futures.Add(Scheduler.Start(
                LoadRecordingMainTask(filename),
                TaskExecutionPolicy.RunAsBackgroundTask
            ));
        }
Beispiel #4
0
        public IEnumerator <object> SaveToDatabase(DatabaseFile db)
        {
            SavedToDatabase = true;

            yield return(db.Snapshots.Set(Index, this.Info));

            {
                var batch = db.Modules.CreateBatch(Modules.Count);

                foreach (var module in Modules)
                {
                    batch.Add(module.Filename, module);
                }

                yield return(batch.Execute());
            }

            yield return(db.SnapshotModules.Set(Index, Modules.Keys.ToArray()));

            {
                var tracebackBatch = db.Tracebacks.CreateBatch(Tracebacks.Count);

                foreach (var traceback in Tracebacks)
                {
                    tracebackBatch.Add(traceback.ID, traceback);
                }

                yield return(tracebackBatch.Execute());
            }

            UInt16 uIndex = (UInt16)Index;

            HashSet <UInt32> addressSet;

            DecisionUpdateCallback <AllocationRanges> rangeUpdater =
                (ref AllocationRanges oldValue, ref AllocationRanges newValue) => {
                var r = newValue.Ranges.Array[newValue.Ranges.Offset];
                newValue = oldValue.Update(r.First, r.TracebackID, r.Size, r.Overhead);
                return(true);
            };

            foreach (var heap in Heaps)
            {
                var fAddressSet = db.HeapAllocations.Get(heap.ID);
                yield return(fAddressSet);

                if (fAddressSet.Failed)
                {
                    addressSet = new HashSet <UInt32>();
                }
                else
                {
                    addressSet = new HashSet <UInt32>(fAddressSet.Result);
                }

                var batch = db.Allocations.CreateBatch(heap.Allocations.Count);

                foreach (var allocation in heap.Allocations)
                {
                    batch.AddOrUpdate(
                        allocation.Address, AllocationRanges.New(
                            uIndex, allocation.TracebackID, allocation.Size, allocation.Overhead
                            ), rangeUpdater
                        );

                    addressSet.Add(allocation.Address);
                }

                yield return(batch.Execute());

                yield return(db.HeapAllocations.Set(heap.ID, addressSet.ToArray()));
            }

            yield return(db.SnapshotHeaps.Set(Index, (from heap in Heaps select heap.Info).ToArray()));
        }
Beispiel #5
0
        public static IEnumerator <object> LoadFromDatabase(DatabaseFile db, HeapSnapshotInfo info)
        {
            var fResult = db.Snapshots.Get(info.Index);

            yield return(fResult);
        }