diff --git a/Granfeldt.SQL.MA/MA/Sql.MA.ImportDetached.cs b/Granfeldt.SQL.MA/MA/Sql.MA.ImportDetached.cs index 074d892..06650a8 100644 --- a/Granfeldt.SQL.MA/MA/Sql.MA.ImportDetached.cs +++ b/Granfeldt.SQL.MA/MA/Sql.MA.ImportDetached.cs @@ -1,4 +1,7 @@ -using System; +// march 2, 2017, soren granfeldt +// -added disposable of dataset and lists after import + +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -208,6 +211,8 @@ IEnumerable DataSetToCsEntryChanges(DataSet records) { csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attr.Name, mvs)); } + mvs.Clear(); + mvs = null; } } } @@ -267,6 +272,8 @@ public OpenImportConnectionResults OpenImportConnectionDetached(KeyedCollection< parameters.Add(new SqlParameter("importtype", ImportType.ToString())); parameters.Add(new SqlParameter("customdata", CustomData)); methods.RunStoredProcedure(Configuration.ImportCommandBefore, parameters); + parameters.Clear(); + parameters = null; } } catch (Exception ex) @@ -319,6 +326,11 @@ public GetImportEntriesResults GetImportEntriesDetached(GetImportEntriesRunStep DataSet records; records = methods.ReadObjects(sqlbatch); importCsEntryQueue.AddRange(DataSetToCsEntryChanges(records)); + records.Clear(); + records.Dispose(); + + sqlbatch.Clear(); + sqlbatch = null; } // return this batch @@ -364,6 +376,8 @@ public CloseImportConnectionResults CloseImportConnectionDetached(CloseImportCon parameters.Add(new SqlParameter("importtype", ImportType.ToString())); parameters.Add(new SqlParameter("customdata", CustomData)); methods.RunStoredProcedure(Configuration.ImportCommandAfter, parameters); + parameters.Clear(); + parameters = null; } methods.CloseConnection(); if (importAnchors != null) @@ -371,6 +385,7 @@ public CloseImportConnectionResults CloseImportConnectionDetached(CloseImportCon importAnchors.Clear(); importAnchors = null; } + GC.Collect(); } catch (Exception ex) { diff --git a/Granfeldt.SQL.MA/Tracer.cs b/Granfeldt.SQL.MA/Tracer.cs index 09d9344..4fd474d 100644 --- a/Granfeldt.SQL.MA/Tracer.cs +++ b/Granfeldt.SQL.MA/Tracer.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics; -using System.Text; namespace Granfeldt { @@ -35,13 +34,9 @@ public static void Enter(string entryPoint) { TraceInformation("enter {0}", entryPoint); Indent(); - Process currentProc = Process.GetCurrentProcess(); - Tracer.TraceInformation("memory-usage {0:n0}Kb, private memomry {1:n0}Kb", GC.GetTotalMemory(true) / 1024, currentProc.PrivateMemorySize64 / 1024); } public static void Exit(string entryPoint) { - Process currentProc = Process.GetCurrentProcess(); - Tracer.TraceInformation("memory-usage {0:n0}Kb, private memory {1:n0}Kb", GC.GetTotalMemory(true) / 1024, currentProc.PrivateMemorySize64 / 1024); Unindent(); TraceInformation("exit {0}", entryPoint); }