mbrimble / biztalkdocumenter

Microsoft Public License
13 stars 9 forks source link

OutOfMemoryException loading schemas suggestion #20

Open EricJanVanBuel opened 1 year ago

EricJanVanBuel commented 1 year ago

When loading a very large schemas that is referenced multiple times in application.schemas an OutOfMemoryException can popup. I suggest to change

  1. BizTalkApplication.cs, move line 262 (s.load()) to within the if statement just below. Add it just before this.schema.add(s) statement. So only loaded when added to hash.
  2. Schema.cs, replace the two 'this.xmlContent=' lines at line 170 with a function ChangeUtf16ToUtf8(schema) call. private void ChangeUtf16ToUtf8(BzTalk.ExplorerOM.Schema schema) { // replace of stringbuilder is much more efficient than a string.replace StringBuilder sTmp = new StringBuilder(schema.XmlContent).Replace("utf-16", "utf-8").Replace("UTF-16", "UTF-8"); this.xmlContent = sTmp.ToString(); sTmp.Clear(); // if necessary, when leaving function this becomes out-of-scope and is for th GC I think }