J
Jagadeesan1993
Guest
I used the Microsoft DataGridView inside the tabcontrol. And assign the binding data source to DataGridView. When I run the sample,the CPU memory takes maximum of 9% alone.But after making any changes in DataGridView by designer and run the sample, now it takes the CPU Memory usage of maximum 16%.And after close the form the CPU memory usage goes to 8%.
Please find the sample from below location,
And also please find the video it shows the memory leak,
The class file code is below,
Public Class EvtClass
#Region "Private Variable Declarations"
Private _ID As Long
Private _StartTimestamp As DateTime
Private _EndTimestamp As DateTime
Private _WO_No As Long
Private _WO_StartTimeDbl As Double
Private _WO_StartTime As DateTime
Private _SKU_No As Long
Private _SKU_Name As String
Private _SKU_Grp As String
Private _EvtNo As Long
Private _ModeNo As Integer
Private _ModeName As String
Private _StateNo As Integer
Private _StateName As String
Private _PLC_DT_Code As Integer
Private _DT_Code As Integer
Private _Dur As Double
Private _DurCat As String
Private _DT_Mach As String
Private _DT_Cat As String
Private _DT_SubCat As String
Private _DT_Reason As String
#End Region
#Region "Public Variable Declarations"
Public Avail As Double
Public Perf As Double
Public Qual As Double
Public OEE As Double
Public TMaxRate As Double
Public WO_PercComplete As Double
Public EstTimeRemaining As Double
#End Region
#Region "Property Definitions"
Public Property ID As Long
Get
Return Me._ID
End Get
Set(value As Long)
Me._ID = value
End Set
End Property
Public Property StartTimestamp As DateTime
Get
Return Me._StartTimestamp
End Get
Set(value As DateTime)
Me._StartTimestamp = value
End Set
End Property
Public Property EndTimestamp As DateTime
Get
Return Me._EndTimestamp
End Get
Set(value As DateTime)
Me._EndTimestamp = value
End Set
End Property
Public Property WO_No As Long
Get
Return Me._WO_No
End Get
Set(value As Long)
Me._WO_No = value
End Set
End Property
Public Property WO_StartTimeDbl As Double
Get
Return Me._WO_StartTimeDbl
End Get
Set(value As Double)
Me._WO_StartTimeDbl = value
End Set
End Property
Public Property WO_StartTime As DateTime
Get
Return Me._WO_StartTime
End Get
Set(value As DateTime)
Me._WO_StartTime = value
End Set
End Property
Public Property SKU_No As Long
Get
Return Me._SKU_No
End Get
Set(value As Long)
Me._SKU_No = value
End Set
End Property
Public Property SKU_Name As String
Get
Return Me._SKU_Name
End Get
Set(value As String)
Me._SKU_Name = value
End Set
End Property
Public Property SKU_Grp As String
Get
Return Me._SKU_Grp
End Get
Set(value As String)
Me._SKU_Grp = value
End Set
End Property
Public Property EvtNo As Long
Get
Return Me._EvtNo
End Get
Set(value As Long)
Me._EvtNo = value
End Set
End Property
Public Property ModeNo As Integer
Get
Return Me._ModeNo
End Get
Set(value As Integer)
Me._ModeNo = value
End Set
End Property
Public Property ModeName As String
Get
Return Me._ModeName
End Get
Set(value As String)
Me._ModeName = value
End Set
End Property
Public Property StateNo As Integer
Get
Return Me._StateNo
End Get
Set(value As Integer)
Me._StateNo = value
End Set
End Property
Public Property StateName As String
Get
Return Me._StateName
End Get
Set(value As String)
Me._StateName = value
End Set
End Property
Public Property PLC_DT_Code As Integer
Get
Return Me._PLC_DT_Code
End Get
Set(value As Integer)
Me._PLC_DT_Code = value
End Set
End Property
Public Property DT_Code As Integer
Get
Return Me._DT_Code
End Get
Set(value As Integer)
Me._DT_Code = value
End Set
End Property
Public Property Dur As Double
Get
Return Me._Dur
End Get
Set(value As Double)
Me._Dur = value
End Set
End Property
Public Property DurCat As String
Get
Return Me._DurCat
End Get
Set(value As String)
Me._DurCat = value
End Set
End Property
Public Property DT_Mach As String
Get
Return Me._DT_Mach
End Get
Set(value As String)
Me._DT_Mach = value
End Set
End Property
Public Property DT_Cat As String
Get
Return Me._DT_Cat
End Get
Set(value As String)
Me._DT_Cat = value
End Set
End Property
Public Property DT_SubCat As String
Get
Return Me._DT_SubCat
End Get
Set(value As String)
Me._DT_SubCat = value
End Set
End Property
Public Property DT_Reason As String
Get
Return Me._DT_Reason
End Get
Set(value As String)
Me._DT_Reason = value
End Set
End Property
#End Region
End Class
And I have initialize the binding data source to DataGridView as below,
Me.EvtClassBindingSource = New System.Windows.Forms.BindingSource(Me.components)
Me.EvtClassBindingSource.DataSource = GetType(miniMonitor.EvtClass)
Me.DataGridView1.DataSource = Me.EvtClassBindingSource
And also I have tried the windows form with binding datasource alone, it takes more CPU memory when making any changes in form. In that below code, I have just initialize the form with binding data source alone,
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form2
Inherits System.Windows.Forms.Form
Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
NOTE: The following procedure is required by the Windows Form Designer
It can be modified using the Windows Form Designer.
Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.EvtClassBindingSource = New System.Windows.Forms.BindingSource(Me.components)
CType(Me.EvtClassBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
components = New System.ComponentModel.Container
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Text = "Form2"
Me.EvtClassBindingSource.DataSource = GetType(miniMonitor.EvtClass)
CType(Me.EvtClassBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents EvtClassBindingSource As System.Windows.Forms.BindingSource
End Class
Continue reading...
Please find the sample from below location,
And also please find the video it shows the memory leak,
The class file code is below,
Public Class EvtClass
#Region "Private Variable Declarations"
Private _ID As Long
Private _StartTimestamp As DateTime
Private _EndTimestamp As DateTime
Private _WO_No As Long
Private _WO_StartTimeDbl As Double
Private _WO_StartTime As DateTime
Private _SKU_No As Long
Private _SKU_Name As String
Private _SKU_Grp As String
Private _EvtNo As Long
Private _ModeNo As Integer
Private _ModeName As String
Private _StateNo As Integer
Private _StateName As String
Private _PLC_DT_Code As Integer
Private _DT_Code As Integer
Private _Dur As Double
Private _DurCat As String
Private _DT_Mach As String
Private _DT_Cat As String
Private _DT_SubCat As String
Private _DT_Reason As String
#End Region
#Region "Public Variable Declarations"
Public Avail As Double
Public Perf As Double
Public Qual As Double
Public OEE As Double
Public TMaxRate As Double
Public WO_PercComplete As Double
Public EstTimeRemaining As Double
#End Region
#Region "Property Definitions"
Public Property ID As Long
Get
Return Me._ID
End Get
Set(value As Long)
Me._ID = value
End Set
End Property
Public Property StartTimestamp As DateTime
Get
Return Me._StartTimestamp
End Get
Set(value As DateTime)
Me._StartTimestamp = value
End Set
End Property
Public Property EndTimestamp As DateTime
Get
Return Me._EndTimestamp
End Get
Set(value As DateTime)
Me._EndTimestamp = value
End Set
End Property
Public Property WO_No As Long
Get
Return Me._WO_No
End Get
Set(value As Long)
Me._WO_No = value
End Set
End Property
Public Property WO_StartTimeDbl As Double
Get
Return Me._WO_StartTimeDbl
End Get
Set(value As Double)
Me._WO_StartTimeDbl = value
End Set
End Property
Public Property WO_StartTime As DateTime
Get
Return Me._WO_StartTime
End Get
Set(value As DateTime)
Me._WO_StartTime = value
End Set
End Property
Public Property SKU_No As Long
Get
Return Me._SKU_No
End Get
Set(value As Long)
Me._SKU_No = value
End Set
End Property
Public Property SKU_Name As String
Get
Return Me._SKU_Name
End Get
Set(value As String)
Me._SKU_Name = value
End Set
End Property
Public Property SKU_Grp As String
Get
Return Me._SKU_Grp
End Get
Set(value As String)
Me._SKU_Grp = value
End Set
End Property
Public Property EvtNo As Long
Get
Return Me._EvtNo
End Get
Set(value As Long)
Me._EvtNo = value
End Set
End Property
Public Property ModeNo As Integer
Get
Return Me._ModeNo
End Get
Set(value As Integer)
Me._ModeNo = value
End Set
End Property
Public Property ModeName As String
Get
Return Me._ModeName
End Get
Set(value As String)
Me._ModeName = value
End Set
End Property
Public Property StateNo As Integer
Get
Return Me._StateNo
End Get
Set(value As Integer)
Me._StateNo = value
End Set
End Property
Public Property StateName As String
Get
Return Me._StateName
End Get
Set(value As String)
Me._StateName = value
End Set
End Property
Public Property PLC_DT_Code As Integer
Get
Return Me._PLC_DT_Code
End Get
Set(value As Integer)
Me._PLC_DT_Code = value
End Set
End Property
Public Property DT_Code As Integer
Get
Return Me._DT_Code
End Get
Set(value As Integer)
Me._DT_Code = value
End Set
End Property
Public Property Dur As Double
Get
Return Me._Dur
End Get
Set(value As Double)
Me._Dur = value
End Set
End Property
Public Property DurCat As String
Get
Return Me._DurCat
End Get
Set(value As String)
Me._DurCat = value
End Set
End Property
Public Property DT_Mach As String
Get
Return Me._DT_Mach
End Get
Set(value As String)
Me._DT_Mach = value
End Set
End Property
Public Property DT_Cat As String
Get
Return Me._DT_Cat
End Get
Set(value As String)
Me._DT_Cat = value
End Set
End Property
Public Property DT_SubCat As String
Get
Return Me._DT_SubCat
End Get
Set(value As String)
Me._DT_SubCat = value
End Set
End Property
Public Property DT_Reason As String
Get
Return Me._DT_Reason
End Get
Set(value As String)
Me._DT_Reason = value
End Set
End Property
#End Region
End Class
And I have initialize the binding data source to DataGridView as below,
Me.EvtClassBindingSource = New System.Windows.Forms.BindingSource(Me.components)
Me.EvtClassBindingSource.DataSource = GetType(miniMonitor.EvtClass)
Me.DataGridView1.DataSource = Me.EvtClassBindingSource
And also I have tried the windows form with binding datasource alone, it takes more CPU memory when making any changes in form. In that below code, I have just initialize the form with binding data source alone,
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form2
Inherits System.Windows.Forms.Form
Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
NOTE: The following procedure is required by the Windows Form Designer
It can be modified using the Windows Form Designer.
Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.EvtClassBindingSource = New System.Windows.Forms.BindingSource(Me.components)
CType(Me.EvtClassBindingSource, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
components = New System.ComponentModel.Container
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Text = "Form2"
Me.EvtClassBindingSource.DataSource = GetType(miniMonitor.EvtClass)
CType(Me.EvtClassBindingSource, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents EvtClassBindingSource As System.Windows.Forms.BindingSource
End Class
Continue reading...