Skip navigation links

MySQL Forums :: Newbie :: System.OutOfMemoryException


Advanced Search

Re: System.OutOfMemoryException
Posted by: Patrick Sullivan ()
Date: August 17, 2007 03:40PM

OK, it looks like I found the bug in the .NET connector 5.0.7 that causes the System.OutOfMemoryException. The problem is that the MySqlConnection::connectionStringCache causes each MySqlConnectionStringBuilder to live forever (one per unique connection string in your application). This would be a good idea except that if the conenction string contains a "database" clause then this triggers MySqlConnection::Open to call MySqlConnection::ChangeDatabase which sets the MySqlConnectionStringBuilder property via "settings.Database = database" (line 346) which calls MySqlConnectionStringBuilder::SetValue which indiscriminately appends the database name to the connection string using "persistConnString.AppendFormat" (line 951), even though it's already there, again, and again, and again....

A correct fix would be to make MySqlConnectionStringBuilder::SetValue(string,object) a little smarter and have it remove a keyword that's already in the string; I can see why this would be difficult, probably not worth the effort.

Another correct fix would be to split MySqlConnection::ChangeDatabase up into the public function that updates the settings.Database and a private helper function that doesn't; and the calling the helper from within MySqlConnection::Open.

A quick fix would be to simply comment out the code related to MySqlConnection::connectionStringCache. This would result in some perofrmance hit.

Edit: Looks like this is already fixed in 5.0.8, http://bugs.mysql.com/bug.php?id=29123



Edited 1 time(s). Last edit at 08/17/2007 04:18PM by Patrick Sullivan.

Options: ReplyQuote


Subject Written By Posted
System.OutOfMemoryException Joe Gates 07/18/2007 12:35PM
Re: System.OutOfMemoryException Patrick Sullivan 08/09/2007 11:09AM
Re: System.OutOfMemoryException Patrick Sullivan 08/17/2007 03:40PM


Sorry, you can't reply to this topic. It has been closed.