title: Looping in to insert bulk data in Oracle is throwing out of memory exception
body: <p>I have a file with 9 million to 13 million records. As the list has a limit size I have broken the code into chunks of 1 million records and trying to insert the record. </p>
  
  <p>Here is code to read and break the file in chunks:</p>
  
  <pre><code>public static void InsertBulkData(string file)
      {
          List&lt;FileData&gt; lstFileData = new List&lt;FileData&gt;();
          using (FileStream fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
          {
              using (BufferedStream bs = new BufferedStream(fs))
              {
                  using (StreamReader sr = new StreamReader(bs))
                  {
                      string line = string.Empty;
                      while ((line = sr.ReadLine()) != null)
                      {
                          FileData obj = new FileData();
                          obj.Property1= line.Substring(5, 9).Trim();
                          obj.Property2= line.Substring(19, 40).Trim();
  
                          lstFileData.Add(obj);
                          if (lstFileData.Count == 1000000)
                          {
                              InsertDataIntoDatabase(lstFileData);
                              lstFileData = null;
                              GC.Collect();
                              lstFileData = new List&lt;FileData&gt;();
  
                          }
  
                      }
  
                  }
              }
          }
      }
  </code></pre>
  
  <p>Now we are getting in the loop 9 times. But when i comes to saving of data it saves for the first time only. rest 8 times it throws exception.</p>
  
  <pre><code>  private static void InsertDataIntoDatabase(List&lt;FileData&gt; lstFileData)
      {
          String query = @"INSERT INTO table
                                          (
                                            PrimaryCol,
                                            Column1,
                                            Column2
  
                                          )
                                          VALUES
                                          (
                                            primaryCol.NEXTVAL,
                                            :Property1,
                                            :Property2,
                                            )";
          using (OracleConnection Conn = new OracleConnection())
          {
              try
              {
                  Conn.ConnectionString = ConfigurationManager.ConnectionStrings["connection"].ToString();
                  Conn.Open();
                  using (var command = Conn.CreateCommand())
                  {
                      command.CommandText = query;
                      command.CommandType = CommandType.Text;
                      command.BindByName = true;
                      // In order to use ArrayBinding, the ArrayBindCount property
                      // of OracleCommand object must be set to the number of records to be inserted
                      command.ArrayBindCount = lstFileData.Count;
                      command.Parameters.Add(":Property1", OracleDbType.Varchar2, lstFileData.Select(c =&gt; c.Property1).ToArray(), ParameterDirection.Input);
                      command.Parameters.Add(":Property2", OracleDbType.Varchar2, lstFileData.Select(c =&gt; c.Property2).ToArray(), ParameterDirection.Input);
  
                      command.ExecuteNonQuery();
                      Conn.Close();
                  }
              }
              catch (Exception ex)
              {
                  Conn.Close();
                  Console.WriteLine("Exception is:" + ex.InnerException);
              }
          }
      }
  </code></pre>
  
  <p>So After first iteration we getting error in command.ExecuteNonQuery(). Can any one tell why and what is the possible solution?</p>