我正在运行带有 Windows 7 PRO 和 64 GB RAM 的 SQL Server 2012 开发人员版。
当我们执行大量内存请求时,我们会抛出 System.OutOfMemoryException。
是否有允许 SQL 使用更多物理 RAM 的快速修复方法?
代码:
// int count = MAX_BARS_IN_MEMORY / tf.timeperiod + 1;
hCommandBars.CommandText = String.Format(@"SELECT top " + MAX_BARS_IN_MEMORY + " * FROM {0} WHERE {0}.timeperiod = " + tf.timeperiod + " ORDER BY {0}.bartime desc", tableName);
barTimesAdapter = new SqlDataAdapter(hCommandBars);
barTimesAdapter.Fill(dTimeset);
foreach (DataTable table in dTimeset.Tables)
{
if (table.Rows.Count > 0)
{
foreach (DataRow row in table.Rows)
{
InMemoryTable inMemorytable = new InMemoryTable();
inMemorytable.BarTime = Convert.ToDateTime((row["bartime"].ToString()));
inMemorytable.High = Convert.ToDouble(row["high"].ToString());
inMemorytable.Low = Convert.ToDouble(row["low"].ToString());
inMemorytable.Open = Convert.ToDouble(row["open"].ToString());
inMemorytable.Close = Convert.ToDouble(row["close"].ToString());
inMemorytable.C1 = Convert.ToDouble(row["c1"].ToString());
inMemorytable.C2 = Convert.ToDouble(row["c2"].ToString());
inMemorytable.SNR2 = false;
inMemorytable.Symbol = symbol.Key;//symbol name
inMemorytable.TimePeriod = Convert.ToInt32(row["timeperiod"].ToString());
_SessAndBarTableList.Add(inMemorytable);
}
}
}
dTimeset.AcceptChanges();
dTimeset.Clear();
}
hConnectionBars.Close();
hConnectionBars.Dispose();
hConnectionBars = null;
//});
}
_SessAndBarTableList = _SessAndBarTableList.OrderBy(x => x.BarTime).ToList();
_1MinuteTableList = _1MinuteTableList.OrderBy(x => x.BarTime).ToList();
}