[Mono-list] Memory leak related with MySql connector

David Cantin david_cantin at videotron.ca
Mon Nov 5 21:39:45 EST 2007


Hi, I got the following class that leak quite much :

using System;
using System.Data;
using MySql.Data.MySqlClient;

namespace MySqlRelatedMemoryLeakTestCase {
        
public class MySqlQueryLauncher {
        
        IDbConnection dbConn; 
        
        public MySqlQueryLauncher() {

                string connectionString =
"Server=localhost;Database=mysql;User ID=user;Password=password;";
                                                
                this.dbConn = new MySqlConnection(connectionString);
                this.dbConn.Open();
                
                this.StressMySql();
        }
        
        private void StressMySql() {
                
                while(true) {
                
                        IDbCommand cmd = this.dbConn.CreateCommand();
                        cmd.CommandText = "SELECT user FROM user";
                        
                        IDataReader reader = cmd.ExecuteReader();
                        
                        while(reader.Read()) {
                                string user = (string) reader["user"];
                        }
                        
                        reader.Close();
                        cmd.Dispose();
                        
                }
        }
}

}

Let this loop run and watch the memory usage of the process...

So, maybe I'm doing something wrong or maybe there is a real leak some
where in the mono code or in the MySql one.

In this example, I use mono 1.2.4 with MySqlConnector (MySql.Data.dll)
5.0.8.1. On the server side, I got MySql 5.0.21-3ubuntu1 (default
install) on ubuntu Dapper Drake.

I have have a simple test case (a monodevelop solution) that trigger the
problem that I can send on request.

I don't known if I should report this to mysql directly or if there is
the right place.

Any advices will be appreciate.

David



More information about the Mono-list mailing list