I have .Net CF 3.5 C# console application on Win CE 6.0 R3 OS and ARM 4i processor with 64 MB RAM and SQL Server CE 3.5 database in my device.
I am using 3 tier architecture
- My project
- BLL
- DAL
In the DAL, I am only creating an object of SqlCeConnection
, calling Object.Open()
and Object.Close()
and in finally block Object.Dispose()
without making any transaction or executing any queries. Find below code snippet.
try
{
lock (_executeScalar)
{
using (_myConnection = new SqlCeConnection("Getting Connection String from App.config"))
{
_myConnection.Open();
_myConnection.Close();
}
}
}
catch(...){ }
finally
{
if (_myConnection.State != ConnectionState.Closed)
_myConnection.Close();
_myConnection.dispose();
}
From my app I am calling the above code snippet infinitely via BLL to DAL in a while loop to check memory leak issue. I also used devhealth60 tool for memory snapshot and observed that every 2-2.5 min some 5 kb (without executing any query like select, insert...) of heap memory of my application increases so as physical memory but not increasing the available virtual memory.
Kindly suggest me how to deal with SQL Server CE 3.5 database in a .Net CF application without any memory leak as I have very frequent use of .sdf
database file from 3 diff apps in my entire project and all apps are never ending so after 1-2 days it stops functioning, required hard reboot.
Any help will be appreciated.
Thanks in advance,
Vijay