Hi,
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 CE 3.5 database in my device.
I am using 3 tier architecture 1. My project, 2. BLL 3. DAL.
In DAL ,I am only Creating an Object of SqlCeConnection , Object.Open() and Object.Close() and in finally block Object.Dispose() without making any transaction or executing any queries. Find below code snippet.
public static void OpenCloseConn()
{
SqlCeConnection _myConnection = null ;
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. 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 CE 3.5 database in .Net CF 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.
I am calling above code from my app as below:
while(true)
{
BLLClass.Instance.OpenCloseSqlCEConnection();
}
In BLL:
public void OpenCloseSqlCEConn()
{
DALClass.Instance.OpenCloseSqlCEConn();
}
In DAL:
public void OpenCloseSqlCEConn()
{
DBHelp.OpenCloseConn();
}
Any help will be appreciated.
Thanks in advance,
Vijay
====EDIT: Please Use Code tags====
CodingK