Hi all, I am querying an SqlCe Database on my PDA and noticed that the device is slowly running out of memory every time I execute a query. I am using the following code:
public SqlCeDataReader ExecuteReader(string command, params SqlCeParameter commandParameters)
SqlCeDataReader reader = null;
SqlCeCommand c = new SqlCeCommand(command, cn);
for (int i = 0; i < commandParameters.Length; i++)
reader = c.ExecuteReader();
// Release resources
This method is a part of my 'SqlCeHelper' class that I have written.
I noticed that when I reach the line reader = c.ExecuteReader() , the memory of my device decreases by about 1%. The reader is returned to a class which makes use of it and then disposes of it by calling reader.Close(); The connection to the database is also closed properly at some point, but memory never gets released. Memory gets only released when the application terminates.
I am wondering if I am doing something wrong by not disposing of some resources. Please help!
(Also tried GC.Collect() , didn't help!)