Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am having a major memory problem. I am loading a DataTable from a MySQL database, but when I dispose the DataTable, no memory is freed. I need to open about 70 tables and dump all the records into another database, but I keep getting an out of memory problem. Can anyone tell me how to completely empty a DataTable from memory? Here is the function I use to load my table:

 

public DataTable SelectSQL_DT(string selectStr, string dtName)
{
try
{
	MySqlConnection dbConnection = 
		new MySqlConnection(connectionString);
	dbConnection.Open();

	MySqlDataAdapter adapter = 
		new MySqlDataAdapter(selectStr, dbConnection);

	DataTable my_table = new DataTable(dtName);
	adapter.Fill(my_table);

	// Dispose of the adapter, it is no longer needed
	adapter.Dispose();

	dbConnection.Close();
	dbConnection.Dispose();
	return my_table;

}
catch (MySqlException e)
{
	throw new Exception("SQL statement execution " +
		"error!!\n\n" + "Trying statement:\n  " + selectStr +
		"\n\n" + e.Message);
}

} //end SelectSQL_DS(string selectStr, string dsName)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...