我运行的.NET 3.5(C#)和SQL Server 2005(为客户)。 我们运行的代码做一些回归数学和有点复杂。 我收到以下错误,当我运行在我们网站上的多个页面:
.NET Framework execution was aborted by escalation policy because of out of memory.
System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
System.InvalidOperationException:
我试图弄清楚什么是这样做的根本原因:这是一个数据库的问题还是我的C代码##? 或者是它运行查询时并发有锁吗? 还是别的什么别的吗?
该代码是示数在这里:
erver.ScriptTimeout = 300;
string returnCode = string.Empty;
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MainDll"].ToString())) {
connection.Open();
using (SqlCommand command = new SqlCommand(sql.ToString(), connection)) {
command.CommandType = CommandType.Text;
command.CommandTimeout = 300;
returnCode = (string)command.ExecuteScalar();
//Dispose();
}
//Dispose();
}
我们的承包商写了一堆代码,以帮助在App_Code文件/文件sqlHelper.s SQL连接。 他们中有些人是这样的:
public static SqlDataReader GetDataReader(string sql, string connectionString, int connectionTime) {
lock (_lock) {
SqlConnection connection = null;
try {
connection = GetConnection(connectionString);
//connection.Open();
using (SqlCommand cmd = new SqlCommand(sql, connection)) {
cmd.CommandTimeout = connectionTime;
WriteDebugInfo("GetDataReader", sql);
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
}
catch (Exception e) {
if (connection != null)
connection.Dispose();
throw new DataException(sql, connectionString, e);
}
}
}
如果有一些内存释放的地方?