Memory Problem when not dispose the DbCommand
---------------------------------------------
Key: DNET-287
URL: http://tracker.firebirdsql.org/browse/DNET-287
Project: .NET Data provider
Issue Type: Bug
Components: ADO.NET Provider
Affects Versions: 2.5.1, 2.1.0
Environment: Windows Vista Home Basic, Visual Studio 2008, .Net
Framework 3.5 SP1, Firebird 2.1.3
Reporter: Nicolas T
Assignee: Jiri Cincura
Priority: Critical
Hello,
Recently we have problem on our aplication when generation long sql inside
transactions like the sample, the problem is the memory increase and them got a
error "Unable to alocate memory from operation system"
The process fbserver.exe increase his memory use until finish all the memory
from the computer and them the error apears
But if i Dispose de componente DbCommand like is comment on the code the
problem dont hapen,
Code Sample
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Common;
using System.Configuration;
using FirebirdSql.Data.FirebirdClient;
namespace WinTestTransaction
{
public partial class Form1 : Form
{
private DbProviderFactory _dbpfactory;
public DbProviderFactory Dbpfactory
{
get { return _dbpfactory; }
set { _dbpfactory = value; }
}
private DbConnection _dbconn;
public DbConnection Dbconn
{
get { return _dbconn; }
set { _dbconn = value; }
}
private DbTransaction _dbtrans;
public DbTransaction Dbtrans
{
get { return _dbtrans; }
set { _dbtrans = value; }
}
private DbCommand _dbcmd;
public DbCommand Dbcmd
{
get { return _dbcmd; }
set { _dbcmd = value; }
}
private DbCommand _dbcmd2;
public DbCommand Dbcmd2
{
get { return _dbcmd2; }
set { _dbcmd2 = value; }
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
Dbpfactory =
DbProviderFactories.GetFactory(ConfigurationManager.AppSettings.Get("provider").ToString());
Dbconn = Dbpfactory.CreateConnection();
Dbconn.ConnectionString =
ConfigurationManager.AppSettings.Get("conexao").ToString();
Dbconn.Open();
Dbtrans = Dbconn.BeginTransaction();
for (int i = 0; i < 500000; i++)
{
Dbcmd = Dbconn.CreateCommand();
Dbcmd.Transaction = Dbtrans;
Dbcmd.Connection = Dbconn;
Dbcmd.CommandType = CommandType.Text;
Dbcmd.CommandText = "INSERT INTO TEST(IDCODIGO,TESTE)
VALUES ('" + i.ToString() + "','" + i.ToString() + "') ";
Dbcmd.Prepare();
Dbcmd.ExecuteNonQuery();
//Dbcmd.Dispose();
}
Dbtrans.Commit();
Dbconn.Close();
MessageBox.Show("OK");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider