Memory Leak

5 posts, 0 answers
  1. Emily Fong
    Emily Fong avatar
    27 posts
    Member since:
    Sep 2012

    Posted 06 Jan 2012 Link to this post

    Hi,

    We have a window application which developing with RadForm and all the radcontrol (Q2 2011 version).  We found that after we close each form, the memory usage in client machine does not release.  We used the JustTrace tool / Net Performance Tool and found that some of the Telerik control was disposed but not in GC.

    We created a testing application to compare the memory usage for RadForm and Window Form.  In the testing application, we have one Window Forms with menu control, one RadForm with RadGridView and one Window Form with RadGridView.  When we run the application, we keep open and close the RadForm 10 times.  Then, we found the memory usage is increase around 5,000k.  However, if we do the same on Window Form, the memory usage is only increase 500k.

    So, how can we release the memory after we close the forms ( before the application was not closed)?

    Code for the Window Form with menu control:
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class Form1
        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.RadContextMenuManager1 = New Telerik.WinControls.UI.RadContextMenuManager()
            Me.MainMenu = New Telerik.WinControls.UI.RadMenu()
            Me.menuFavorites = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuCode = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuMaster = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuPrice = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuPO = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuSO = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuInventory = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuInvoice = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuEnquiry = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuAccount = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuMobile = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuWindow = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuHelp = New Telerik.WinControls.UI.RadMenuItem()
            Me.menuTheme = New Telerik.WinControls.UI.RadMenuItem()
            CType(Me.MainMenu, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            '
            'MainMenu
            '
            Me.MainMenu.CausesValidation = False
            Me.MainMenu.Font = New System.Drawing.Font("Verdana", 9.0!)
            Me.MainMenu.Items.AddRange(New Telerik.WinControls.RadItem() {Me.menuFavorites, Me.menuCode, Me.menuMaster, Me.menuPrice, Me.menuPO, Me.menuSO, Me.menuInventory, Me.menuInvoice, Me.menuEnquiry, Me.menuAccount, Me.menuMobile, Me.menuWindow, Me.menuHelp, Me.menuTheme})
            Me.MainMenu.Location = New System.Drawing.Point(0, 0)
            Me.MainMenu.Name = "MainMenu"
            '
            '
            '
            Me.MainMenu.RootElement.AccessibleDescription = Nothing
            Me.MainMenu.RootElement.AccessibleName = Nothing
            Me.MainMenu.RootElement.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.MainMenu.RootElement.AngleTransform = 0.0!
            Me.MainMenu.RootElement.FlipText = False
            Me.MainMenu.RootElement.Margin = New System.Windows.Forms.Padding(0)
            Me.MainMenu.RootElement.Padding = New System.Windows.Forms.Padding(0)
            Me.MainMenu.RootElement.Text = Nothing
            Me.MainMenu.RootElement.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.MainMenu.Size = New System.Drawing.Size(752, 38)
            Me.MainMenu.TabIndex = 7
            '
            'menuFavorites
            '
            Me.menuFavorites.AccessibleDescription = "&Favorites"
            Me.menuFavorites.AccessibleName = "&Favorites"
            Me.menuFavorites.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuFavorites.AngleTransform = 0.0!
            Me.menuFavorites.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren
            Me.menuFavorites.Class = ""
            Me.menuFavorites.FlipText = False
            Me.menuFavorites.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuFavorites.ForeColor = System.Drawing.SystemColors.ControlText
            Me.menuFavorites.Image = Nothing
            Me.menuFavorites.ImageIndex = -1
            Me.menuFavorites.ImageKey = ""
            Me.menuFavorites.Margin = New System.Windows.Forms.Padding(0)
            Me.menuFavorites.Name = "menuFavorites"
            Me.menuFavorites.Padding = New System.Windows.Forms.Padding(0)
            Me.menuFavorites.RightToLeft = False
            Me.menuFavorites.Tag = ""
            Me.menuFavorites.Text = "&Favorites"
            Me.menuFavorites.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuFavorites.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuFavorites.Visibility = Telerik.WinControls.ElementVisibility.Visible
            '
            'menuCode
            '
            Me.menuCode.AccessibleDescription = "&Code"
            Me.menuCode.AccessibleName = "&Code"
            Me.menuCode.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuCode.AngleTransform = 0.0!
            Me.menuCode.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren
            Me.menuCode.Class = ""
            Me.menuCode.DescriptionFont = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuCode.FlipText = False
            Me.menuCode.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuCode.Image = Nothing
            Me.menuCode.ImageIndex = -1
            Me.menuCode.ImageKey = ""
            Me.menuCode.Margin = New System.Windows.Forms.Padding(0)
            Me.menuCode.Name = "menuCode"
            Me.menuCode.Padding = New System.Windows.Forms.Padding(0)
            Me.menuCode.RightToLeft = False
            Me.menuCode.ShowArrow = False
            Me.menuCode.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuCode.Text = "&Code"
            Me.menuCode.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuCode.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuCode.Visibility = Telerik.WinControls.ElementVisibility.Visible
            '
            'menuMaster
            '
            Me.menuMaster.AccessibleDescription = "&Master"
            Me.menuMaster.AccessibleName = "&Master"
            Me.menuMaster.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuMaster.AngleTransform = 0.0!
            Me.menuMaster.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren
            Me.menuMaster.Class = ""
            Me.menuMaster.DescriptionFont = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuMaster.FlipText = False
            Me.menuMaster.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuMaster.Image = Nothing
            Me.menuMaster.ImageIndex = -1
            Me.menuMaster.ImageKey = ""
            Me.menuMaster.Margin = New System.Windows.Forms.Padding(0)
            Me.menuMaster.Name = "menuMaster"
            Me.menuMaster.Padding = New System.Windows.Forms.Padding(0)
            Me.menuMaster.RightToLeft = False
            Me.menuMaster.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuMaster.Text = "&Master"
            Me.menuMaster.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuMaster.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuMaster.Visibility = Telerik.WinControls.ElementVisibility.Visible
            '
            'menuPrice
            '
            Me.menuPrice.AccessibleDescription = "&Price && Promotion"
            Me.menuPrice.AccessibleName = "&Price && Promotion"
            Me.menuPrice.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuPrice.AngleTransform = 0.0!
            Me.menuPrice.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren
            Me.menuPrice.Class = ""
            Me.menuPrice.DescriptionFont = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuPrice.FlipText = False
            Me.menuPrice.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuPrice.Image = Nothing
            Me.menuPrice.ImageIndex = -1
            Me.menuPrice.ImageKey = ""
            Me.menuPrice.Margin = New System.Windows.Forms.Padding(0)
            Me.menuPrice.Name = "menuPrice"
            Me.menuPrice.Padding = New System.Windows.Forms.Padding(0)
            Me.menuPrice.RightToLeft = False
            Me.menuPrice.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuPrice.Text = "&Price && Promotion"
            Me.menuPrice.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuPrice.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuPrice.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            '
            'menuPO
            '
            Me.menuPO.AccessibleDescription = "&Purchase Order"
            Me.menuPO.AccessibleName = "&Purchase Order"
            Me.menuPO.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuPO.AngleTransform = 0.0!
            Me.menuPO.Class = ""
            Me.menuPO.DescriptionFont = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuPO.FlipText = False
            Me.menuPO.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuPO.Image = Nothing
            Me.menuPO.ImageIndex = -1
            Me.menuPO.ImageKey = ""
            Me.menuPO.Margin = New System.Windows.Forms.Padding(0)
            Me.menuPO.Name = "menuPO"
            Me.menuPO.Padding = New System.Windows.Forms.Padding(0)
            Me.menuPO.RightToLeft = False
            Me.menuPO.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuPO.Text = "&Purchase Order"
            Me.menuPO.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuPO.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuPO.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            '
            'menuSO
            '
            Me.menuSO.AccessibleDescription = "&Sales Order"
            Me.menuSO.AccessibleName = "&Sales Order"
            Me.menuSO.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuSO.AngleTransform = 0.0!
            Me.menuSO.Class = ""
            Me.menuSO.DescriptionFont = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuSO.FlipText = False
            Me.menuSO.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuSO.Image = Nothing
            Me.menuSO.ImageIndex = -1
            Me.menuSO.ImageKey = ""
            Me.menuSO.Margin = New System.Windows.Forms.Padding(0)
            Me.menuSO.Name = "menuSO"
            Me.menuSO.Padding = New System.Windows.Forms.Padding(0)
            Me.menuSO.RightToLeft = False
            Me.menuSO.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuSO.Text = "&Sales Order"
            Me.menuSO.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuSO.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuSO.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            '
            'menuInventory
            '
            Me.menuInventory.AccessibleDescription = "&Inventory"
            Me.menuInventory.AccessibleName = "&Inventory"
            Me.menuInventory.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuInventory.AngleTransform = 0.0!
            Me.menuInventory.Class = ""
            Me.menuInventory.DescriptionFont = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuInventory.FlipText = False
            Me.menuInventory.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuInventory.Image = Nothing
            Me.menuInventory.ImageIndex = -1
            Me.menuInventory.ImageKey = ""
            Me.menuInventory.Margin = New System.Windows.Forms.Padding(0)
            Me.menuInventory.Name = "menuInventory"
            Me.menuInventory.Padding = New System.Windows.Forms.Padding(0)
            Me.menuInventory.RightToLeft = False
            Me.menuInventory.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuInventory.Text = "&Inventory"
            Me.menuInventory.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuInventory.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuInventory.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            '
            'menuInvoice
            '
            Me.menuInvoice.AccessibleDescription = "&Invoice"
            Me.menuInvoice.AccessibleName = "&Invoice"
            Me.menuInvoice.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuInvoice.AngleTransform = 0.0!
            Me.menuInvoice.Class = ""
            Me.menuInvoice.DescriptionFont = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuInvoice.FlipText = False
            Me.menuInvoice.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuInvoice.Image = Nothing
            Me.menuInvoice.ImageIndex = -1
            Me.menuInvoice.ImageKey = ""
            Me.menuInvoice.Margin = New System.Windows.Forms.Padding(0)
            Me.menuInvoice.Name = "menuInvoice"
            Me.menuInvoice.Padding = New System.Windows.Forms.Padding(0)
            Me.menuInvoice.RightToLeft = False
            Me.menuInvoice.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuInvoice.Text = "&Invoice"
            Me.menuInvoice.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuInvoice.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuInvoice.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            '
            'menuEnquiry
            '
            Me.menuEnquiry.AccessibleDescription = "&Enquiry"
            Me.menuEnquiry.AccessibleName = "&Enquiry"
            Me.menuEnquiry.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuEnquiry.AngleTransform = 0.0!
            Me.menuEnquiry.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren
            Me.menuEnquiry.Class = ""
            Me.menuEnquiry.DescriptionFont = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuEnquiry.FlipText = False
            Me.menuEnquiry.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuEnquiry.Image = Nothing
            Me.menuEnquiry.ImageIndex = -1
            Me.menuEnquiry.ImageKey = ""
            Me.menuEnquiry.Margin = New System.Windows.Forms.Padding(0)
            Me.menuEnquiry.Name = "menuEnquiry"
            Me.menuEnquiry.Padding = New System.Windows.Forms.Padding(0)
            Me.menuEnquiry.RightToLeft = False
            Me.menuEnquiry.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuEnquiry.Text = "&Enquiry"
            Me.menuEnquiry.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuEnquiry.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuEnquiry.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            '
            'menuAccount
            '
            Me.menuAccount.AccessibleDescription = "Account"
            Me.menuAccount.AccessibleName = "Account"
            Me.menuAccount.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuAccount.AngleTransform = 0.0!
            Me.menuAccount.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.WrapAroundChildren
            Me.menuAccount.Class = ""
            Me.menuAccount.DescriptionFont = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuAccount.FlipText = False
            Me.menuAccount.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuAccount.Image = Nothing
            Me.menuAccount.ImageIndex = -1
            Me.menuAccount.ImageKey = ""
            Me.menuAccount.Margin = New System.Windows.Forms.Padding(0)
            Me.menuAccount.MaxSize = New System.Drawing.Size(0, 0)
            Me.menuAccount.Name = "menuAccount"
            Me.menuAccount.Padding = New System.Windows.Forms.Padding(0)
            Me.menuAccount.RightToLeft = False
            Me.menuAccount.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuAccount.Text = "Account"
            Me.menuAccount.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuAccount.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuAccount.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            '
            'menuMobile
            '
            Me.menuMobile.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuMobile.AngleTransform = 0.0!
            Me.menuMobile.Class = ""
            Me.menuMobile.FlipText = False
            Me.menuMobile.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuMobile.Image = Nothing
            Me.menuMobile.ImageIndex = -1
            Me.menuMobile.ImageKey = ""
            Me.menuMobile.Margin = New System.Windows.Forms.Padding(0)
            Me.menuMobile.Name = "menuMobile"
            Me.menuMobile.Padding = New System.Windows.Forms.Padding(0)
            Me.menuMobile.RightToLeft = False
            Me.menuMobile.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuMobile.Text = ""
            Me.menuMobile.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuMobile.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuMobile.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
            '
            'menuWindow
            '
            Me.menuWindow.AccessibleDescription = "Windows"
            Me.menuWindow.AccessibleName = "Windows"
            Me.menuWindow.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuWindow.AngleTransform = 0.0!
            Me.menuWindow.Class = ""
            Me.menuWindow.FitToSizeMode = Telerik.WinControls.RadFitToSizeMode.FitToParentContent
            Me.menuWindow.FlipText = False
            Me.menuWindow.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuWindow.Image = Nothing
            Me.menuWindow.ImageIndex = -1
            Me.menuWindow.ImageKey = ""
            Me.menuWindow.Margin = New System.Windows.Forms.Padding(0)
            Me.menuWindow.MdiList = True
            Me.menuWindow.Name = "menuWindow"
            Me.menuWindow.Padding = New System.Windows.Forms.Padding(0)
            Me.menuWindow.RightToLeft = False
            Me.menuWindow.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuWindow.Tag = "視窗"
            Me.menuWindow.Text = "Windows"
            Me.menuWindow.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuWindow.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuWindow.Visibility = Telerik.WinControls.ElementVisibility.Visible
            '
            'menuHelp
            '
            Me.menuHelp.AccessibleDescription = "&Help"
            Me.menuHelp.AccessibleName = "&Help"
            Me.menuHelp.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuHelp.AngleTransform = 0.0!
            Me.menuHelp.Class = ""
            Me.menuHelp.FlipText = False
            Me.menuHelp.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuHelp.Image = Nothing
            Me.menuHelp.ImageIndex = -1
            Me.menuHelp.ImageKey = ""
            Me.menuHelp.Margin = New System.Windows.Forms.Padding(0)
            Me.menuHelp.Name = "menuHelp"
            Me.menuHelp.Padding = New System.Windows.Forms.Padding(0)
            Me.menuHelp.RightToLeft = False
            Me.menuHelp.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuHelp.Text = "&Help"
            Me.menuHelp.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuHelp.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuHelp.Visibility = Telerik.WinControls.ElementVisibility.Hidden
            '
            'menuTheme
            '
            Me.menuTheme.AccessibleDescription = "Theme"
            Me.menuTheme.AccessibleName = "Theme"
            Me.menuTheme.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.menuTheme.AngleTransform = 0.0!
            Me.menuTheme.Class = ""
            Me.menuTheme.Enabled = False
            Me.menuTheme.FlipText = False
            Me.menuTheme.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            Me.menuTheme.Image = Nothing
            Me.menuTheme.ImageIndex = -1
            Me.menuTheme.ImageKey = ""
            Me.menuTheme.Margin = New System.Windows.Forms.Padding(0)
            Me.menuTheme.Name = "menuTheme"
            Me.menuTheme.Padding = New System.Windows.Forms.Padding(0)
            Me.menuTheme.RightToLeft = False
            Me.menuTheme.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
            Me.menuTheme.Text = "Theme"
            Me.menuTheme.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter
            Me.menuTheme.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.menuTheme.Visibility = Telerik.WinControls.ElementVisibility.Hidden
            '
            'Form1
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(752, 338)
            Me.Controls.Add(Me.MainMenu)
            Me.IsMdiContainer = True
            Me.Name = "Form1"
            Me.Text = "Form1"
            CType(Me.MainMenu, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
            Me.PerformLayout()
     
        End Sub
        Friend WithEvents RadContextMenuManager1 As Telerik.WinControls.UI.RadContextMenuManager
        Friend WithEvents MainMenu As Telerik.WinControls.UI.RadMenu
        Friend WithEvents menuFavorites As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuCode As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuMaster As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuPrice As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuPO As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuSO As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuInventory As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuInvoice As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuEnquiry As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuAccount As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuMobile As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuWindow As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuHelp As Telerik.WinControls.UI.RadMenuItem
        Friend WithEvents menuTheme As Telerik.WinControls.UI.RadMenuItem
     
    End Class


    vb code:
    Public Class Form1
        Private WithEvents frmRad As RadForm1
        Private WithEvents frmForm As Form2
     
        Private Sub menuCode_Click(sender As System.Object, e As System.EventArgs) Handles menuCode.Click
            frmRad = New RadForm1
            frmRad.Show()
        End Sub
     
        Private Sub menuMaster_Click(sender As System.Object, e As System.EventArgs) Handles menuMaster.Click
            frmForm = New Form2
            frmForm.Show()
        End Sub
     
        Private Sub frmForm_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles frmForm.FormClosed
            frmForm = Nothing
        End Sub
     
        Private Sub frmRad_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles frmRad.FormClosed
            frmRad = Nothing
        End Sub
    End Class


    RadForm:
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class RadForm1
        Inherits Telerik.WinControls.UI.RadForm
     
        '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.RadGridView1 = New Telerik.WinControls.UI.RadGridView()
            CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            '
            'RadGridView1
            '
            Me.RadGridView1.Location = New System.Drawing.Point(32, 23)
            Me.RadGridView1.Name = "RadGridView1"
            Me.RadGridView1.Size = New System.Drawing.Size(240, 150)
            Me.RadGridView1.TabIndex = 1
            Me.RadGridView1.Text = "RadGridView1"
            '
            'RadForm1
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(308, 292)
            Me.Controls.Add(Me.RadGridView1)
            Me.Name = "RadForm1"
            '
            '
            '
            Me.RootElement.ApplyShapeToControl = True
            Me.Text = "RadForm1"
            CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
     
        End Sub
        Friend WithEvents RadGridView1 As Telerik.WinControls.UI.RadGridView
    End Class

    Window Form with RadGridView:
    <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.RadGridView1 = New Telerik.WinControls.UI.RadGridView()
            CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            '
            'RadGridView1
            '
            Me.RadGridView1.Location = New System.Drawing.Point(12, 12)
            Me.RadGridView1.Name = "RadGridView1"
            Me.RadGridView1.Size = New System.Drawing.Size(240, 150)
            Me.RadGridView1.TabIndex = 0
            Me.RadGridView1.Text = "RadGridView1"
            '
            'Form2
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(284, 262)
            Me.Controls.Add(Me.RadGridView1)
            Me.Name = "Form2"
            Me.Text = "Form2"
            CType(Me.RadGridView1, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
     
        End Sub
        Friend WithEvents RadGridView1 As Telerik.WinControls.UI.RadGridView
    End Class

    Best Regards,
    Emily
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 09 Jan 2012 Link to this post

    Hi Emily, 

    Thank you for writing.

    I want to share with you that RadForm/Form is a disposable object and you have to call its Dispose method explicitly, for example:

    using(Form2 newform = newForm2())
    {
       newform.ShowDialog();
    }

    I also want to share with you that the Garbage Collector releases the instance of RadControls later than it frees less complex controls. The reason is that RadControls is a second generation Garbage Collector object. If you want to release the memory instantly after the form is closed, you should call the GC.Collect method manually. Consider the code snippet below: 

    myForm.Close();
    myForm.Dispose();
    GC.Collect();
    GC.WaitForFullGCApproach();
    GC.WaitForFullGCComplete();
    GC.WaitForPendingFinalizers();
    GC.Collect();

    More information on garbage collection generations can be found here.

    In addition, our themes create static objects that remain active in memory until the application is closed. This can raise the application memory with several megabytes.

    If you continue to experience issues, please send us your project and we will investigate further.
    I am looking forward to your reply.

    Kind regards,
    Peter
    the Telerik team

    SP1
    of Q3’11 of RadControls for WinForms is available for download (see what's new).
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Emily Fong
    Emily Fong avatar
    27 posts
    Member since:
    Sep 2012

    Posted 13 Jan 2012 Link to this post

    Thanks!

    However, we found any memory leaks problem. Please help to handle it.
    In a Radform, we have a RadGridView with datetimecolumn.  We click the calendar in grid column to select a date and close the form.  Then, in .NET Memory Profiler, we found that there is a RadCalendar control is directly rooted by an EventHandler and that Eventhandler has not been properly removed.
    So, how can we remove that EventHandler since that RadCalendar is created by RadGridView control?

    The following are our sample coding:
    MdiForm:
    Public Class Form1
        Private WithEvents radform As RadForm1
     
        Private Sub RadMenuItem1_Click(sender As Object, e As System.EventArgs) Handles RadMenuItem1.Click
            radform = New RadForm1
            radform.MdiParent = Me
            radform.Top = 0
            radform.Left = 0
            radform.Show()
        End Sub
     
        Private Sub radform_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles radform.FormClosed
            radform.Dispose()
            radform = Nothing
            GC.Collect()
            GC.WaitForFullGCApproach()
            GC.WaitForFullGCComplete()
            GC.WaitForPendingFinalizers()
            GC.Collect()
     
        End Sub
    End Class

    ChildForm (with GridView):
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class RadForm1
        Inherits Telerik.WinControls.UI.RadForm
     
        '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()
            Dim GridViewDateTimeColumn1 As Telerik.WinControls.UI.GridViewDateTimeColumn = New Telerik.WinControls.UI.GridViewDateTimeColumn()
            Me.rgvEnquiry = New Telerik.WinControls.UI.RadGridView()
            CType(Me.rgvEnquiry, System.ComponentModel.ISupportInitialize).BeginInit()
            CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
            Me.SuspendLayout()
            '
            'rgvEnquiry
            '
            Me.rgvEnquiry.BackColor = System.Drawing.Color.FromArgb(CType(CType(191, Byte), Integer), CType(CType(219, Byte), Integer), CType(CType(255, Byte), Integer))
            Me.rgvEnquiry.Cursor = System.Windows.Forms.Cursors.Default
            Me.rgvEnquiry.Dock = System.Windows.Forms.DockStyle.Fill
            Me.rgvEnquiry.Font = New System.Drawing.Font("Verdana", 9.0!)
            Me.rgvEnquiry.ForeColor = System.Drawing.Color.Black
            Me.rgvEnquiry.ImeMode = System.Windows.Forms.ImeMode.NoControl
            Me.rgvEnquiry.Location = New System.Drawing.Point(0, 0)
            '
            'rgvEnquiry
            '
            Me.rgvEnquiry.MasterTemplate.AllowColumnChooser = False
            Me.rgvEnquiry.MasterTemplate.AllowDeleteRow = False
            Me.rgvEnquiry.MasterTemplate.AutoExpandGroups = True
            GridViewDateTimeColumn1.HeaderText = "column1"
            GridViewDateTimeColumn1.Name = "column1"
            GridViewDateTimeColumn1.Width = 140
            Me.rgvEnquiry.MasterTemplate.Columns.AddRange(New Telerik.WinControls.UI.GridViewDataColumn() {GridViewDateTimeColumn1})
            Me.rgvEnquiry.MasterTemplate.EnableAlternatingRowColor = True
            Me.rgvEnquiry.MasterTemplate.EnableFiltering = True
            Me.rgvEnquiry.MasterTemplate.ShowChildViewCaptions = True
            Me.rgvEnquiry.MasterTemplate.ShowGroupedColumns = True
            Me.rgvEnquiry.MasterTemplate.ShowParentGroupSummaries = True
            Me.rgvEnquiry.Name = "rgvEnquiry"
            Me.rgvEnquiry.ReadOnly = True
            Me.rgvEnquiry.RightToLeft = System.Windows.Forms.RightToLeft.No
            '
            '
            '
            Me.rgvEnquiry.RootElement.AccessibleDescription = Nothing
            Me.rgvEnquiry.RootElement.AccessibleName = Nothing
            Me.rgvEnquiry.RootElement.Alignment = System.Drawing.ContentAlignment.TopLeft
            Me.rgvEnquiry.RootElement.AngleTransform = 0.0!
            Me.rgvEnquiry.RootElement.FlipText = False
            Me.rgvEnquiry.RootElement.ForeColor = System.Drawing.Color.Black
            Me.rgvEnquiry.RootElement.Margin = New System.Windows.Forms.Padding(0)
            Me.rgvEnquiry.RootElement.Padding = New System.Windows.Forms.Padding(0)
            Me.rgvEnquiry.RootElement.Text = Nothing
            Me.rgvEnquiry.RootElement.TextOrientation = System.Windows.Forms.Orientation.Horizontal
            Me.rgvEnquiry.ShowChildViewCaptions = True
            Me.rgvEnquiry.Size = New System.Drawing.Size(798, 441)
            Me.rgvEnquiry.TabIndex = 5
            '
            'RadForm1
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(798, 441)
            Me.Controls.Add(Me.rgvEnquiry)
            Me.Name = "RadForm1"
            '
            '
            '
            Me.RootElement.ApplyShapeToControl = True
            Me.Text = "RadForm1"
            CType(Me.rgvEnquiry, System.ComponentModel.ISupportInitialize).EndInit()
            CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
            Me.ResumeLayout(False)
     
        End Sub
        Friend WithEvents rgvEnquiry As Telerik.WinControls.UI.RadGridView
    End Class

    Emily
  5. Emily Fong
    Emily Fong avatar
    27 posts
    Member since:
    Sep 2012

    Posted 17 Jan 2012 Link to this post

    Is there any advise?
  6. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 18 Jan 2012 Link to this post

    Hi Emily,

    Thank you for writing back and for the provided details.

    Despite our efforts, our tests did not show memory leaks in a similar scenario and I was not able to identify a memory leak in our test application. Therefore, could you please provide me with your application and exact steps to reproduce the issue in it, so that we can locate it and address it further?

    Thank you for your time and cooperation. Please note that you have to open a new support ticket in order to be able to attach files.

    All the best,
    Peter
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top
UI for WinForms is Visual Studio 2017 Ready