public override void BuildNode(ITreeBuilder builder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
        {
            HeapBuddyProfilingSnapshot snapshot = (HeapBuddyProfilingSnapshot)dataObject;

            label = snapshot.Name;
            icon  = Context.GetIcon("md-prof-gc");
            snapshot.NameChanged += nameChangedHandler;
        }
        public override void BuildChildNodes(ITreeBuilder builder, object dataObject)
        {
            HeapBuddyProfilingSnapshot snapshot = (HeapBuddyProfilingSnapshot)dataObject;

            builder.AddChild(new HistoryNode(snapshot));
            builder.AddChild(new TypesNode(snapshot));
            builder.AddChild(new BacktracesNode(snapshot));
            builder.Expanded = true;
        }
Esempio n. 3
0
        public void Load(HeapBuddyProfilingSnapshot snapshot)
        {
            this.snapshot = snapshot;

            foreach (Type type in snapshot.Outfile.Types)
            {
                store.AppendValues("md-class", type.Name, type.LastObjectStats.AllocatedCount.ToString(),
                                   ProfilingService.PrettySize(type.LastObjectStats.AllocatedTotalBytes),
                                   String.Format("{0:0.0}", type.LastObjectStats.AllocatedAverageBytes),
                                   String.Format("{0:0.0}", type.LastObjectStats.AllocatedAverageAge),
                                   type.BacktraceCount.ToString(), type);
            }
        }
Esempio n. 4
0
        private void AsyncTakeSnapshot(object state)
        {
            string dumpFile = null;

            lock (sync)
                dumpFile = Context.FileName;

            int  attempts = 40;
            bool success  = false;

            while (!success)
            {
                if (--attempts == 0)
                {
                    OnSnapshotFailed(EventArgs.Empty);
                    return;
                }

                Thread.Sleep(500);
                if (!File.Exists(dumpFile))
                {
                    continue;
                }

                try {
                    string destFile = GetSaveLocation();
                    if (destFile != null)                       //ignore if Cancel is clicked in the save dialog
                    {
                        File.Copy(dumpFile, destFile);
                        File.Delete(dumpFile);

                        IProfilingSnapshot snapshot = new HeapBuddyProfilingSnapshot(this, destFile);
                        OnSnapshotTaken(new ProfilingSnapshotEventArgs(snapshot));
                    }
                    success = true;
                } catch (Exception ex) {
                    LoggingService.LogError("HeapBuddyProfiler", "AsyncTakeSnapshot", ex);
                }
            }

            Stop();
        }
Esempio n. 5
0
        public void Load(HeapBuddyProfilingSnapshot snapshot)
        {
            this.snapshot = snapshot;

            foreach (Backtrace bt in snapshot.Outfile.Backtraces)
            {
                TreeIter iter = store.AppendValues("md-class", bt.Type.Name, bt.LastObjectStats.AllocatedCount.ToString(),
                                                   ProfilingService.PrettySize(bt.LastObjectStats.AllocatedTotalBytes),
                                                   String.Format("{0:0.0}", bt.LastObjectStats.AllocatedAverageBytes),
                                                   String.Format("{0:0.0}", bt.LastObjectStats.AllocatedAverageAge), bt);

                foreach (Frame frame in bt.Frames)
                {
                    if (!frame.MethodName.StartsWith("(wrapper"))
                    {
                        store.AppendValues(iter, "md-method", frame.MethodName, String.Empty, String.Empty,
                                           String.Empty, String.Empty, frame);
                    }
                }
            }
        }
Esempio n. 6
0
		public TypesNode (HeapBuddyProfilingSnapshot snapshot)
			: base (snapshot)
		{
		}
Esempio n. 7
0
		public BaseNode (HeapBuddyProfilingSnapshot snapshot)
		{
			this.snapshot = snapshot;
		}
Esempio n. 8
0
		public HistoryNode (HeapBuddyProfilingSnapshot snapshot)
			: base (snapshot)
		{
		}
Esempio n. 9
0
 public TypesNode(HeapBuddyProfilingSnapshot snapshot)
     : base(snapshot)
 {
 }
Esempio n. 10
0
 public HistoryNode(HeapBuddyProfilingSnapshot snapshot)
     : base(snapshot)
 {
 }
Esempio n. 11
0
 public BacktracesNode(HeapBuddyProfilingSnapshot snapshot)
     : base(snapshot)
 {
 }
        public override string GetNodeName(ITreeNavigator thisNode, object dataObject)
        {
            HeapBuddyProfilingSnapshot snapshot = (HeapBuddyProfilingSnapshot)dataObject;

            return(snapshot.Name);
        }
Esempio n. 13
0
 public BaseNode(HeapBuddyProfilingSnapshot snapshot)
 {
     this.snapshot = snapshot;
 }
Esempio n. 14
0
		public BacktracesNode (HeapBuddyProfilingSnapshot snapshot)
			: base (snapshot)
		{
		}
Esempio n. 15
0
		public void Load (HeapBuddyProfilingSnapshot snapshot)
		{
			this.snapshot = snapshot;
			
			foreach (Type type in snapshot.Outfile.Types) {
				store.AppendValues ("md-class", type.Name, type.LastObjectStats.AllocatedCount.ToString (),
					ProfilingService.PrettySize (type.LastObjectStats.AllocatedTotalBytes),
					String.Format ("{0:0.0}", type.LastObjectStats.AllocatedAverageBytes),
					String.Format ("{0:0.0}", type.LastObjectStats.AllocatedAverageAge),
					type.BacktraceCount.ToString (), type);
			}
		}
Esempio n. 16
0
		public void Load (HeapBuddyProfilingSnapshot snapshot)
		{
			this.snapshot = snapshot;

			foreach (Backtrace bt in snapshot.Outfile.Backtraces) {
				TreeIter iter = store.AppendValues ("md-class", bt.Type.Name, bt.LastObjectStats.AllocatedCount.ToString (),
					ProfilingService.PrettySize (bt.LastObjectStats.AllocatedTotalBytes),
					String.Format ("{0:0.0}", bt.LastObjectStats.AllocatedAverageBytes),
					String.Format ("{0:0.0}", bt.LastObjectStats.AllocatedAverageAge), bt);
				
				foreach (Frame frame in bt.Frames) {
					if (!frame.MethodName.StartsWith ("(wrapper"))
						store.AppendValues (iter, "md-method", frame.MethodName, String.Empty, String.Empty,
							String.Empty, String.Empty, frame);
				}
			}
		}
Esempio n. 17
0
        public void Load(HeapBuddyProfilingSnapshot snapshot)
        {
            this.snapshot = snapshot;
            OutfileReader reader = snapshot.Outfile;

            Resize[] resizes = reader.Resizes;
            Gc[]     gcs     = reader.Gcs;

            int  i_resize  = 0;
            int  i_gc      = 0;
            long heap_size = 0;

            while (i_resize < resizes.Length || i_gc < gcs.Length)
            {
                Resize r = null;
                if (i_resize < resizes.Length)
                {
                    r = resizes [i_resize];
                }

                Gc gc = null;
                if (i_gc < gcs.Length)
                {
                    gc = gcs [i_gc];
                }

                string timestamp, tag, message;

                if (r != null && (gc == null || r.Generation <= gc.Generation))
                {
                    timestamp = string.Format("{0:HH:mm:ss}", r.Timestamp);

                    if (r.PreviousSize == 0)
                    {
                        tag     = GettextCatalog.GetString("Init");
                        message = String.Format(GettextCatalog.GetString("Initialized heap to {0}"),
                                                ProfilingService.PrettySize(r.NewSize));
                    }
                    else
                    {
                        tag     = GettextCatalog.GetString("Resize");
                        message = String.Format(GettextCatalog.GetString("Grew heap from {0} to {1}") +
                                                Environment.NewLine +
                                                GettextCatalog.GetString("{2} in {3} live objects") +
                                                Environment.NewLine +
                                                GettextCatalog.GetString("Heap went from {4:0.0}% to {5:0.0}% capacity"),
                                                ProfilingService.PrettySize(r.PreviousSize),
                                                ProfilingService.PrettySize(r.NewSize),
                                                ProfilingService.PrettySize(r.TotalLiveBytes),
                                                r.TotalLiveObjects,
                                                r.PreResizeCapacity, r.PostResizeCapacity);
                    }

                    heap_size = r.NewSize;
                    ++i_resize;
                }
                else
                {
                    timestamp = String.Format("{0:HH:mm:ss}", gc.Timestamp);
                    if (gc.Generation >= 0)
                    {
                        tag     = GettextCatalog.GetString("GC ") + gc.Generation;
                        message = String.Format(GettextCatalog.GetString("Collected {0} of {1} objects ({2:0.0}%)") +
                                                Environment.NewLine +
                                                GettextCatalog.GetString("Collected {3} of {4} ({5:0.0}%)") +
                                                Environment.NewLine +
                                                GettextCatalog.GetString("Heap went from {6:0.0}% to {7:0.0}% capacity"),
                                                gc.FreedObjects,
                                                gc.PreGcLiveObjects,
                                                gc.FreedObjectsPercentage,
                                                ProfilingService.PrettySize(gc.FreedBytes),
                                                ProfilingService.PrettySize(gc.PreGcLiveBytes),
                                                gc.FreedBytesPercentage,
                                                100.0 * gc.PreGcLiveBytes / heap_size,
                                                100.0 * gc.PostGcLiveBytes / heap_size);
                    }
                    else
                    {
                        tag     = GettextCatalog.GetString("Exit");
                        message = String.Format(GettextCatalog.GetString("{0} live objects using {1}"),
                                                gc.PreGcLiveObjects,
                                                ProfilingService.PrettySize(gc.PreGcLiveBytes));
                    }
                    ++i_gc;
                }

                store.AppendValues(timestamp, tag, message);
            }
        }
Esempio n. 18
0
		public void Load (HeapBuddyProfilingSnapshot snapshot)
		{
			this.snapshot = snapshot;
			OutfileReader reader = snapshot.Outfile;

			Resize[] resizes = reader.Resizes;
			Gc[] gcs = reader.Gcs;

			int i_resize = 0;
			int i_gc = 0;
			long heap_size = 0;

			while (i_resize < resizes.Length || i_gc < gcs.Length) {
				
				Resize r = null;
				if (i_resize < resizes.Length)
					r = resizes [i_resize];
				
				Gc gc = null;
				if (i_gc < gcs.Length)
					gc = gcs [i_gc];

				string timestamp, tag, message;

				if (r != null && (gc == null || r.Generation <= gc.Generation)) {
					timestamp = string.Format ("{0:HH:mm:ss}", r.Timestamp);

					if (r.PreviousSize == 0) {
						tag =  GettextCatalog.GetString ("Init");
						message = String.Format (GettextCatalog.GetString ("Initialized heap to {0}"),
							ProfilingService.PrettySize (r.NewSize));
					} else {
						tag =  GettextCatalog.GetString ("Resize");
						message = String.Format (GettextCatalog.GetString ("Grew heap from {0} to {1}") +
							Environment.NewLine +
							GettextCatalog.GetString ("{2} in {3} live objects") +
							Environment.NewLine +
							GettextCatalog.GetString ("Heap went from {4:0.0}% to {5:0.0}% capacity"),
							ProfilingService.PrettySize (r.PreviousSize),
							ProfilingService.PrettySize (r.NewSize),
							ProfilingService.PrettySize (r.TotalLiveBytes),
							r.TotalLiveObjects,
							r.PreResizeCapacity, r.PostResizeCapacity);
					}

					heap_size = r.NewSize;
					++i_resize;

				} else {
					timestamp = String.Format ("{0:HH:mm:ss}", gc.Timestamp);
					if (gc.Generation >= 0) {
						tag =  GettextCatalog.GetString ("GC ") + gc.Generation;
						message = String.Format (GettextCatalog.GetString ("Collected {0} of {1} objects ({2:0.0}%)") +
							Environment.NewLine +
							GettextCatalog.GetString ("Collected {3} of {4} ({5:0.0}%)") +
						        Environment.NewLine +
							GettextCatalog.GetString ("Heap went from {6:0.0}% to {7:0.0}% capacity"),
							gc.FreedObjects,
							gc.PreGcLiveObjects,
							gc.FreedObjectsPercentage,
							ProfilingService.PrettySize (gc.FreedBytes),
							ProfilingService.PrettySize (gc.PreGcLiveBytes),
							gc.FreedBytesPercentage,
							100.0 * gc.PreGcLiveBytes / heap_size,
							100.0 * gc.PostGcLiveBytes / heap_size);
					} else {
						tag = GettextCatalog.GetString ("Exit");
						message = String.Format (GettextCatalog.GetString ("{0} live objects using {1}"),
									 gc.PreGcLiveObjects,
									 ProfilingService.PrettySize (gc.PreGcLiveBytes));
					}
					++i_gc;
				}

				store.AppendValues (timestamp, tag, message);
			}
		}
Esempio n. 19
0
		private void AsyncTakeSnapshot (object state)
		{
			string dumpFile = null;
			lock (sync)
				dumpFile = Context.FileName;
			
			int attempts = 40;
			bool success = false;
			
			while (!success) {
				if (--attempts == 0) {
					OnSnapshotFailed (EventArgs.Empty);
					return;
				}
				
				Thread.Sleep (500);
				if (!File.Exists (dumpFile))
					continue;

				try {
					string destFile = GetSaveLocation ();
					if (destFile != null) { //ignore if Cancel is clicked in the save dialog
						File.Copy (dumpFile, destFile);
						File.Delete (dumpFile);

						IProfilingSnapshot snapshot = new HeapBuddyProfilingSnapshot (this, destFile);
						OnSnapshotTaken (new ProfilingSnapshotEventArgs (snapshot));
					}
					success = true;
				} catch (Exception ex) {
					LoggingService.LogError ("HeapBuddyProfiler", "AsyncTakeSnapshot", ex);
				}
			}
			
			Stop ();
		}