测试应用:
static void Main(string[] args)
{
String connectionString = "DSN=DotNetUltraLightDSII; UID=user; PWD=pass";
String query = "select * from person";
using (OdbcConnection connection = new OdbcConnection(connectionString))
{
connection.Open();
for (Int32 trial = 1; trial <= 100000; trial++)
{
if (0 == trial % 1000)
{
Console.WriteLine("Executing trial #{0:#,0}", trial);
GC.Collect();
}
using (OdbcCommand command = new OdbcCommand(query, connection))
{
using (OdbcDataReader reader = command.ExecuteReader())
{
do
{
while (reader.Read())
{
for (Int32 colIndex = 0; colIndex < reader.FieldCount; colIndex++)
{
Object x = reader[colIndex];
IDisposable d = x as IDisposable;
if (null != d)
{
d.Dispose();
}
d = null;
x = null;
}
}
} while (reader.NextResult());
reader.Close();
}
}
}
connection.Close();
}
Memory usage Heap Snapshot Comparison
随着时间的推移,内存使用率会上升。似乎ULPersonTable有强大的手柄,但我无法确定这些强大的手柄是什么或它们来自何处。我们将这种类型的实例存储在gcroot中,但它们似乎被破坏了。如果有人能够对这个问题有所了解,那将不胜感激。
此致
答案 0 :(得分:0)
结束发现问题。这是一个没有被正确删除的指针。