在Win CE 6.0 R3板上仅执行打开/关闭Sql CE数据库连接时内存增加 [英] Memory increases while performing only Open/Close Sql CE database connection on Win CE 6.0 R3 board

查看:59
本文介绍了在Win CE 6.0 R3板上仅执行打开/关闭Sql CE数据库连接时内存增加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在Win CE 6.0 R3 OS和ARM 4i处理器上安装了.Net CF 3.5 C#控制台应用程序,64 MB RAM和Sql CE 3.5数据库我的设备。



我正在使用3层架构1.我的项目,2。BLL 3. DAL。



在DAL中,我只创建一个SqlCeConnection,Object.Open()和Object.Close()的对象,最后阻止Object.Dispose()而不进行任何事务或执行任何查询。找到下面的代码片段。



  public   static   void  OpenCloseConn()
{
SqlCeConnection _myConnection = null ;
尝试
{
lock (_ executeScalar)
{
使用(_ myConnection = new SqlCeConnection( 从App.config获取连接字符串))
{
_myConnection.Open();

_myConnection.Close();
}
}
}
catch (...){}
finally
{
if (_ myConnection.State!= ConnectionState.Closed)
_myConnection。关();
_myConnection.dispose();
}
}





从我的应用程序中,我通过BLL到DAL无限地调用上面的代码片段while循环检查内存泄漏问题。还使用devhealth60工具进行内存快照,并观察到我的应用程序堆内存每2-2.5 Min大约5 kb(不执行任何查询,如select,insert ...)会增加物理内存但不会增加可用的虚拟内存。



请建议我如何处理.Net CF中的Sql CE 3.5数据库,没有任何内存泄漏,因为我经常使用来自3个差异应用程序的.sdf数据库文件在我的整个项目中,所有的应用程序永远不会结束,所以1-2天之后它就会停止运行,需要硬重启。



我从我的应用程序调用上面的代码,如下所示:



  while  true 
{
BLLClass.Instance.OpenCloseSqlCEConnection();
}

在BLL中:

public void OpenCloseSqlCEConn()
{
DALClass.Instance.OpenCloseSqlCEConn();
}

在DAL中:
public void OpenCloseSqlCEConn()
{
DBHelp.OpenCloseConn(); // DBHelp中的方法(所有数据库操作的类)class
}







如有任何帮助,我们将不胜感激。



在此先感谢,



Vijay



====编辑:请使用代码标签=== =

CodingK

解决方案

你不太可能在.net中出现内存泄漏,而且很可能微软会测试与SqlCe的互操作性问题和.net



内存使用在.net中很自然,CLR会在下一个GC循环中释放未使用的内存,所以你不必担心它。

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(); // method present in DBHelp(class for all Database operaions) class
}




Any help will be appreciated.

Thanks in advance,

Vijay

====EDIT: Please Use Code tags====
CodingK

解决方案

It is highly unlikely you will have memory leaks in .net and most certainly Microsoft will have tested interoperability issues with SqlCe and .net

Memory usage is natural in .net, and the CLR will free unused memory in the next GC cycle so you should not worry about it.


这篇关于在Win CE 6.0 R3板上仅执行打开/关闭Sql CE数据库连接时内存增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆