FileMaker的ODBC驱动程序不会释放句柄(内存泄漏) [英] FileMaker's ODBC Driver doesn't release Handles (memory leak)

查看:212
本文介绍了FileMaker的ODBC驱动程序不会释放句柄(内存泄漏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

整天跟踪我的VB.NET项目中的内存泄漏后,我已将原因归结为FileMaker的ODBC驱动程序的错误!

After a whole day tracking down a memory leak in my VB.NET project, I have traced the cause to a bug with FileMaker's ODBC driver !

要重现,您需要一个可以连接的数据库(我在Server Advanced 11.0.3上托管了该数据库,但您也可以在本地托管它),并且在PC上注册/安装了ODBC驱动程序(我测试了版本) 11.3和12.0,以及最新的12.2).

To reproduce you'll need a database you can connect to (I have mine hosted on Server Advanced 11.0.3, but you can also host it locally), and the ODBC driver registered/installed on the PC (I tested versions 11.3 and 12.0, and the latest 12.2).

启动一个新的VB.NET WinForms项目,将一个按钮添加到表单并将此代码粘贴到该按钮的click事件上:

Start a new VB.NET WinForms project, add a button to the form and paste this code onto the button's click event:

Using cn_FM As New Odbc.OdbcConnection("DRIVER={FileMaker ODBC};SERVER=192.168.1.xxx;UID=admin;PWD=admin;DATABASE=test;")
    cn_FM.Open()
End Using

此代码所做的全部工作是打开一个到FileMaker数据库的连接,但是,如果您在Windows Task Manager中分析内存使用情况,则可以很容易地看到(通过反复单击刚创建的按钮)cn_FM没有被正确处理.因为句柄不断增加!我尝试强制执行垃圾回收,但是此操作无济于事,因此我认为驱动程序本身有问题.

All this code does is open a connection to a FileMaker database, however if you analyse the memory usage in Windows Task Manager you can easily see (by repeatedly clicking the button you just made) that cn_FM is not being disposed properly because the Handles keep increasing! I tried forcing Garbage Collection but this didn't do anything, so I assume its a problem with the driver itself.

哦,我测试了以相同的方式连接到SQL数据库,并且正如您所期望的那样,没有句柄泄漏...

Oh, and I tested connecting to a SQL database in the same way, and as you would expect, there was no handle leakage...

任何人都可以确认这是正确的吗?

Can anyone confirm this is correct?

编辑:我尝试了各种打开和关闭连接的方法,以及实际在数据库中查询using块中的内容.还尝试过在本地托管fp7文件,但还是不行:(

I tried various ways of opening and closing the connection, as well as actually querying the database for something in the using block. Also tried hosting the fp7 file locally, but still no go :(

推荐答案

我通过建立持久连接(声明并打开一次并保持打开状态)来解决此问题.但是我每次使用时都要检查它是否仍然打开,例如:

I got around this problem by making a persistent connection (declare and open it once and leave it open). But I need to check if its still open each time I want to use it, for example:

Public Sub CheckOpen(ByRef cn As Odbc.OdbcConnection)
    If cn.State <> System.Data.ConnectionState.Open Then
        cn.Close()
        cn.Open()
    End If
End Sub

如果您有多个FM数据库文件,则可能意味着您需要为每个文件建立一个连接.

If you have multiple FM database files then this may mean you need to have one connection for each file.

侧面说明:在FMSA上运行的FileMaker的xdbc_listener.exe进程也泄漏.我们注意到一种模式,一旦其使用的内存不足2GB,它就会崩溃.因此请记住,该过程可能需要不断重启.

Side Note: FileMaker's xdbc_listener.exe process running on FMSA is also leaky. We have noticed a pattern that once it reaches just under 2GB memory usage it crashes. So keep in mind that the process may need constant restarting.

这篇关于FileMaker的ODBC驱动程序不会释放句柄(内存泄漏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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