I am trying to locate a memory leak in my application. I would appreciate some assistance in understanding whether the disposal of mySQLCommand is operating correctly. I have run the following test code, and using a memory profiler, I see that there are up to 10,000 datareaders which remain undisposed during the life of the application. I presume that ExecuteNonQuery calls the datareader internally. Are these datareaders just waiting for the next run of the garbage collector before they will be disposed, or is this the source of the memory leak?
Many thanks.
Dim x As Integer
Dim mySQLcnn As New CoreLab.MySql.MySqlConnection("user id=xray_engine;host=localhost;database=control;direct=True;protocol=Tcp;pooling=False")
Dim mySQLcmd As New CoreLab.MySql.MySqlCommand
mySQLcmd.Connection = mySQLcnn
mySQLcnn.Open()
mySQLcmd.CommandText = "select * from urlid limit 1"
For x = 0 To 10000000
mySQLcmd.ExecuteNonQuery()
TextBox1.Text = x
Next
mySQLcnn.Close()