I have been having issues with what appear to be memory leaks when using Telerik WinControls. I first noticed the issue in a form that we have that has dozens of controls on it, and which increases the memory usage by upwards of 40 MB when shown. However, I then made a new project, simply dragged a few controls onto the form, and I am seeing the exact same issue, just on a smaller scale. When the application first starts, memory usage is around 18 MB, but by the time it is done, usage is around 40 MB. The code that I am running the test with is:
Public Class Main
Shared Sub Main()
MessageBox.Show("Start")
For i = 0 To 50 Step 1
Dim f As New Form1
f.Show()
Threading.Thread.Sleep(100)
f.Close()
f.Dispose()
Next
GC.Collect()
MessageBox.Show("Stop")
End Sub
End Class
The controls that I used the designer to add to the form are:
Friend WithEvents RadMenu1 As Telerik.WinControls.UI.RadMenu
Friend WithEvents RadButton1 As Telerik.WinControls.UI.RadButton
Friend WithEvents RadTextBox1 As Telerik.WinControls.UI.RadTextBox
Friend WithEvents RadSplitButton1 As Telerik.WinControls.UI.RadSplitButton
Friend WithEvents RadCarousel1 As Telerik.WinControls.UI.RadCarousel
Friend WithEvents RadButton2 As Telerik.WinControls.UI.RadButton
What am I doing wrong? Using some memory profiling tools, it looks like there may be timers still running or other event handlers registered that are preventing the controls from being garbage collected.
Is there something special that needs to be done to clean up after the Telerik controls?
Due to the size of the form we are using in real life, this can quickly cause the application to be using 100's of MB's of memory, which has actually led to out-of-memory issues in some cases.
Thanks for your help!