Memory leak in DataAdapter.Fill() or maybe more general question

  • Thread starter Thread starter sanchez911
  • Start date Start date
S

sanchez911

Guest
Hi all!

I have server application that consumes too much memory.. It takes about 600 mb RAM after 1-2 days of working.
So I tried to profile app with VS2010 profiler. But it's report does not give usefull (for me) information.
For example, it just says that 70% of memory is used by type "string" or char[]. But what strings? The most memory consuming function is DbDataAdapter.Fill (30% of all app memory). But why? There is only 1 function that uses Fill method:

...
DataSet dataSet = new DataSet();

SqlDataAdapter adapter = new SqlDataAdapter();
SqlCommand command = new SqlCommand(query, connection);
command.CommandType = CommandType.Text;
adapter.SelectCommand = command;
adapter.Fill(dataSet);
query_succesfull = true;
query_executed = true;
adapter.Dispose();
return dataSet.Tables[0];


So I can't understand why this happens. At first I thought that it was SqlDataAdapter that is not disposed by GC. But I didn't get any result even after adding adapter.Dispose().

The SQL table in query is not big (~20 varchar columns and ~100 rows). Resulting dataset is used only few times and then GC should destroy it (but I don't know if GC is really doing it).

So maybe you can advice me how can I find reasons of .net internal method high memory consumption? Thank you!

P.S. There is only one possible reason that I guess: most of cases of using Fill() method are placed in Timer elapsed event handler. Somewhere I read that GC can not clean objects that are created in timer event handler. But there is no any detailed information about this.

Continue reading...
 
Back
Top