B
Ben
I have a program that invokes the following block of code every x
seconds. The process private bytes keeps increasing after every call.
I've try to dispose the SQlDataAdapter in the finally block, but did
not work. If I invoke the garbage collector manually GC.Collect in the
finally block, there is no more memory leak. What's wrong with the
following block of code? Is there a real leak or am I missing
something?
I've been working on this for few days, but I cannot figure it out.
Please help!
private DataSet GetJobQ()
{
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection( "myconnectionstring" );
SqlDataAdapter adpt = new SqlDataAdapter( "EXEC GetJobQ", conn );
try
{
adpt.Fill( ds );
}
finally
{
con.Close();
}
return ds;
}
seconds. The process private bytes keeps increasing after every call.
I've try to dispose the SQlDataAdapter in the finally block, but did
not work. If I invoke the garbage collector manually GC.Collect in the
finally block, there is no more memory leak. What's wrong with the
following block of code? Is there a real leak or am I missing
something?
I've been working on this for few days, but I cannot figure it out.
Please help!
private DataSet GetJobQ()
{
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection( "myconnectionstring" );
SqlDataAdapter adpt = new SqlDataAdapter( "EXEC GetJobQ", conn );
try
{
adpt.Fill( ds );
}
finally
{
con.Close();
}
return ds;
}