Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Problem when not dispose the DbCommand [DNET288] #299

Closed
firebird-automations opened this issue Jan 15, 2010 · 3 comments
Closed

Comments

@firebird-automations
Copy link

Submitted by: Nicolas T (nftimmers)

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\);
       \}
   \}

}

}

@firebird-automations
Copy link
Author

Commented by: @pcisar

This was formerly DNET287 before tracker crash

@firebird-automations
Copy link
Author

Modified by: @pcisar

reporter: Pavel Cisar [ pcisar ] => Nicolas T [ nftimmers ]

priority: Major [ 3 ] => Critical [ 2 ]

security: Managers [ 10013 ] =>

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Closed [ 6 ]

resolution: Won't Fix [ 2 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants