In the MySQL5.5 environment, the ConnectorNet version is 6.8.3.0, and the memory and handle are leaked when a connection exception is opened. I wrote a small program to test it: privatevoidHandleLeak () {DbConnection
In the MySQL5.5 environment, the Connector/Net version is 6.8.3.0, and the memory and handle are leaked when a connection exception is opened. I wrote a small program to test it: privatevoidHandleLeak () {DbConnection
In the MySQL 5.5 environment, the Connector/Net version is 6.8.3.0, and the memory and handle are leaked when a connection exception is opened. Write a small program to test it:
Private void HandleLeak () {DbConnection conn = null; while (true) {try {// the server can be connected, but the password is incorrect, when opening, predictionconn = new MySqlConnection ("Server = localhost; Database = test; Uid = username; Pwd = wrong password"); conn. open ();} catch {// clear conn. close (); conn. dispose (); conn = null; Console. writeLine ("Connect Error");} finally {Thread. sleep (1000 );}}}
In the task manager, we observe that the number of handles has been increasing, but the same code is no problem if changed to SqlServer. After using ProcessXp, the process occupies a large number of TCP connections and is in the CLOSE_WAIT status. The connection between the Process and the server is not properly closed, using netstat-ano | findstr "3306", you can see that mysqld.exe (PID: 1900) has a large number of connections in the FIN_WAIT_2 state.
In terms of status, it seems that after the login fails, the server actively disconnects, but the client does not close the tcp connection correctly. For details, refer to the source code of Connector, but it is not available now, wait for a while. Some experts know the problem and leave a comment.
In addition, if GC. Collect () is executed, the handle will not be leaked.
This article is from the "Rabbit nest" blog. Please keep this source