1

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

  1. My project
  2. BLL
  3. 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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Vijay_007
  • 11
  • 2
  • where is _myConnection declared - in other words, try: using (var _myConnection ... {} – ErikEJ Nov 21 '14 at 12:14
  • Which SQL CE 3.5 build do you use? many updates have been released – ErikEJ Nov 21 '14 at 12:16
  • @ErikEJ _myConnection is declared as a SqlCeConnection _myConnection = null just before try block. and Sql CE buid is 3.5.5386.0 – Vijay_007 Nov 24 '14 at 05:42
  • Try (using..) as mentioned in my first comment, and the latest versions are listed here: http://erikej.blogspot.dk/2010/08/sql-server-compact-35-sp2-downloadable.html – ErikEJ Nov 24 '14 at 07:34
  • @ErikEJ tried as mentioned in your first comment, but then also application's heap was 2.72 mb on start and after continuous running for 18 hours heap increased up to 3.45 mb – Vijay_007 Nov 26 '14 at 05:09
  • Did you update to a recent build? – ErikEJ Nov 26 '14 at 08:32

0 Answers0