Informix的内存泄漏 [英] Informix memory leak

查看:561
本文介绍了Informix的内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Informix(具体地说,我使用的是IBM.Data.Informix命名空间,4.10客户端SDK)运行到一个奇怪的问题。我连接到IBM Informix数据库使用ODBC和正在运行到内存泄漏问题。该文件是相当稀疏,我锁定到使用的驱动程序/ SDK我目前已经安装了。下面是我使用的数据库上下文中的代码:

I am running into an strange issue using Informix (specifically, I am using the IBM.Data.Informix namespace, 4.10 Client SDK). I am connecting to an IBM Informix database using ODBC and am running into memory leak issues. The documentation is fairly sparse, and I am locked into using the driver/SDK I currently have installed. Here is the code I am using for the database context:

public class IfxDbContext : IIfxDbContext
{
    private readonly string _connectionString;
    //private readonly IfxConnection _connection;

    public IfxDbContext(string connectionString)
    {
        _connectionString = connectionString;
        //IfxConnection conn = new IfxConnection(connectionString) {ConnectionString = connectionString};

        //_connection = conn;
    }

    public IEnumerable<Item> GetItems()
    {
        var items = new List<Item>();

        try
        {
            using (IfxConnection conn = new IfxConnection(_connectionString))
            {
                conn.Open();

                using (IfxCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "VALID SQL COMMAND";

                    IfxDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        //add to items
                    }
                }
            }
        }
        catch(IfxException ex)
        {

        }

        return items;
    }
}



}

}

我已经试过处置和关闭任何连接,我可以,但似乎并没有帮助。我缺少的东西或者是它的驱动程序问题?那么问题就变成,我能做些什么来逐步释放内存?该应用程序打左右〜1200 MB和崩溃。

I have tried disposing and closing any connection I can, but that doesn't seem to help. Am I missing something or is it an issue with the driver? The question then becomes, what can I do to free up memory incrementally? The app hits around ~1200 MB and crashes.

我的具体错误是为解析器堆栈没有足够的空间和内存分配失败。

My particular errors are "Not enough space for parser stacks" and "Memory allocation failure".

我缺少的东西吗?

推荐答案

原来,这是与特定版本的问题SDK的我使用的项目(4.10 - 32位)。除非你离开两者的连接和命令无限期地开放,应用程序将导致内存泄漏。这是不是一个真正的解决方案,因为有连接的数量有限,并且很快用完了,如果我要申请多个连接。因为我需要继续使用这个特定的SDK版本,我配置IIS以回收应用程序池,当它达到内存阈值(1 GB在我的实例)。这解决了这个问题,现在,虽然它无助于解决与SDK底层的问题。

Turns out that this is an issue with the specific version of the SDK I am using for the project (4.10 - 32 bit). Unless you leave both the connection and the command open indefinitely, the application will leak memory. This isn't really a solution because there is a finite number of connections and that quickly runs out if I have multiple connections to the application. Because I need to continue using this specific SDK version, I configured IIS to recycle the app pool when it reached a memory threshold (1 GB in my instance). That resolved the issue for now, although it does nothing to address the underlying issue with the SDK.

这篇关于Informix的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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