From 52a54501c32b08f6d38bde04e98e36aee527e87b Mon Sep 17 00:00:00 2001 From: dathlin Date: Wed, 28 Jun 2017 18:41:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=AF=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=80=E4=B8=AA=E6=98=BE=E7=A4=BA=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E5=86=85=E5=AD=98=E4=BD=BF=E7=94=A8=E6=83=85=E5=86=B5?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormServerWindow.Designer.cs | 58 ++++++++++++++++++- 软件系统服务端模版/FormServerWindow.cs | 19 ++++-- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/软件系统服务端模版/FormServerWindow.Designer.cs b/软件系统服务端模版/FormServerWindow.Designer.cs index fa01791..bd697ce 100644 --- a/软件系统服务端模版/FormServerWindow.Designer.cs +++ b/软件系统服务端模版/FormServerWindow.Designer.cs @@ -57,6 +57,10 @@ this.label1 = new System.Windows.Forms.Label(); this.listBox1 = new System.Windows.Forms.ListBox(); this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label_GC_Memery = new System.Windows.Forms.Label(); + this.label_Pm_Memery = new System.Windows.Forms.Label(); this.statusStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -269,18 +273,64 @@ | System.Windows.Forms.AnchorStyles.Right))); this.label5.Font = new System.Drawing.Font("微软雅黑", 21F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label5.ForeColor = System.Drawing.Color.RoyalBlue; - this.label5.Location = new System.Drawing.Point(10, 38); + this.label5.Location = new System.Drawing.Point(10, 30); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(744, 36); + this.label5.Size = new System.Drawing.Size(548, 45); this.label5.TabIndex = 13; this.label5.Text = "XXXXX系统"; this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // label6 + // + this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(564, 37); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(59, 17); + this.label6.TabIndex = 14; + this.label6.Text = "对象内存:"; + // + // label7 + // + this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(564, 58); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(59, 17); + this.label7.TabIndex = 15; + this.label7.Text = "进程内存:"; + // + // label_GC_Memery + // + this.label_GC_Memery.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label_GC_Memery.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.label_GC_Memery.Location = new System.Drawing.Point(629, 37); + this.label_GC_Memery.Name = "label_GC_Memery"; + this.label_GC_Memery.Size = new System.Drawing.Size(125, 17); + this.label_GC_Memery.TabIndex = 16; + this.label_GC_Memery.Text = "0"; + this.label_GC_Memery.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // label_Pm_Memery + // + this.label_Pm_Memery.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label_Pm_Memery.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.label_Pm_Memery.Location = new System.Drawing.Point(629, 58); + this.label_Pm_Memery.Name = "label_Pm_Memery"; + this.label_Pm_Memery.Size = new System.Drawing.Size(125, 17); + this.label_Pm_Memery.TabIndex = 17; + this.label_Pm_Memery.Text = "0"; + this.label_Pm_Memery.TextAlign = System.Drawing.ContentAlignment.TopRight; + // // FormServerWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(764, 481); + this.Controls.Add(this.label_Pm_Memery); + this.Controls.Add(this.label_GC_Memery); + this.Controls.Add(this.label7); + this.Controls.Add(this.label6); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.textBox1); @@ -334,6 +384,10 @@ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_time; private System.Windows.Forms.ToolStripMenuItem 框架作者ToolStripMenuItem; private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label_GC_Memery; + private System.Windows.Forms.Label label_Pm_Memery; } } diff --git a/软件系统服务端模版/FormServerWindow.cs b/软件系统服务端模版/FormServerWindow.cs index 9a9a36e..a6e0e36 100644 --- a/软件系统服务端模版/FormServerWindow.cs +++ b/软件系统服务端模版/FormServerWindow.cs @@ -761,6 +761,20 @@ namespace 软件系统服务端模版 thread.IsBackground = true; thread.Start(); } + /// + /// 缓存的上次内存占用 + /// + private long GC_Memery { get; set; } + + private void MethodOccurEverySecond() + { + long current = GC.GetTotalMemory(false); + toolStripStatusLabel_time.Text = DateTime.Now.ToString(); + label_GC_Memery.Text = current.ToString(); + label_GC_Memery.BackColor = current < GC_Memery ? Color.Tomato : SystemColors.Control; + GC_Memery = current; + } + public void ThreadTimeTick() { @@ -769,10 +783,7 @@ namespace 软件系统服务端模版 int minute = -1; int hour = -1; int day = -1; - Action DTimeShow = delegate - { - toolStripStatusLabel_time.Text = DateTime.Now.ToString(); - }; + Action DTimeShow = MethodOccurEverySecond; while (IsWindowShow) {