我也遇到了MYSQL应用程序批量插数据时,程序内存一直增长!搞了两天,终于发现,不是My.ini的调参的问题,而是在执行插入后,声明的MySqlCommand对象没有明确析构的问题。public override int ExecuteNonQuery(string commandText){ MySqlConnection conn = null;MySqlCommand sqlcommand = null;try { using (...
mysql消耗的内存为什么总是逐渐增加
我也遇到了MYSQL应用程序批量插数据时,程序内存一直增长!搞了两天,终于发现,不是My.ini的调参的问题,而是在执行插入后,声明的MySqlCommand对象没有明确析构的问题。
public override int ExecuteNonQuery(string commandText)
{
MySqlConnection conn = null;
MySqlCommand sqlcommand = null;
try
{
using (conn = new MySqlConnection(ConnectionString))
{
conn.Open();
sqlcommand = new MySqlCommand(commandText, conn) ;
int res = sqlcommand.ExecuteNonQuery();
return res;
}
}
catch (Exception ex)
{
MessageBox.Show(string.Format("数据库连接或查询失败!\r\n{0}", ex.Message), "错误", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return -1;
}
finally
{
if (sqlcommand != null) sqlcommand.Dispose();//缺少这句话,内存会一直增长!
if (conn != null) conn.Close();
}
}2017-03-04
当然连接数*相关内存参数也是会消耗的,还一些全局的2017-01-19
有 oom 的可能性存在2017-01-20