<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Problem with memory when write to GML file in ArcGIS Runtime SDK for WPF (Retired) Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/problem-with-memory-when-write-to-gml-file/m-p/70591#M306</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try&lt;BR /&gt; {&lt;BR /&gt; //Set Folder permission&lt;BR /&gt; SetFullAccessPermissionsForEveryone(Path.GetTempPath());&lt;BR /&gt; string tempPath = Path.Combine(Path.GetTempPath(), "Temp");&lt;BR /&gt; string tempPath1 = Path.Combine(tempPath, "buildings.gml");&lt;/P&gt;&lt;P&gt;if (File.Exists(tempPath1))&lt;BR /&gt; {&lt;BR /&gt; File.Delete(tempPath1);&lt;BR /&gt; }&lt;BR /&gt; List&amp;lt;double&amp;gt; CoordX = new List&amp;lt;double&amp;gt;();&lt;BR /&gt; List&amp;lt;double&amp;gt; CoordY = new List&amp;lt;double&amp;gt;();&lt;BR /&gt; int k = 0;&lt;BR /&gt; &lt;BR /&gt; char[] delimiters = new char[] { ',' };&lt;BR /&gt; for (int i = 0; i &amp;lt; _overlay_Graphic.Graphics.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; if (_overlay_Graphic.Graphics&lt;I&gt;.Attributes.Count &amp;gt; 0)&lt;BR /&gt; {&lt;BR /&gt; var coords = _overlay_Graphic.Graphics&lt;I&gt;.Geometry as Multipart;&lt;BR /&gt; var points = coords.Parts.First().Points;&lt;BR /&gt; for (int j = 0; j &amp;lt; points.Count; j++)&lt;BR /&gt; {&lt;BR /&gt; MapPoint point = new MapPoint(Math.Round(Convert.ToDouble(points&lt;J&gt;.X),2), Math.Round(Convert.ToDouble(points&lt;J&gt;.Y),2), new SpatialReference(WKID));&lt;BR /&gt; MapPoint pointUTM = (MapPoint)GeometryEngine.Project(point, new SpatialReference(WKID));&lt;BR /&gt; CoordX.Add(pointUTM.X);&lt;BR /&gt; CoordY.Add(pointUTM.Y);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; XNamespace akn = "http://www.openplans.org/topp";&lt;BR /&gt; XNamespace wfs = "http://www.opengis.net/wfs";&lt;BR /&gt; XNamespace xs = "http://www.w3.org/2001/XMLSchema";&lt;BR /&gt; XNamespace arec = "http://mak.arec/";&lt;BR /&gt; XNamespace gml = "http://www.opengis.net/gml";&lt;BR /&gt; XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";&lt;BR /&gt; XNamespace schemaLocation = XNamespace.Get("http://www.openplans.org/topp http://128.128.0.105/MakEditProxy/dzgr_parc_trans.xsd http://www.opengis.net/wfs http://128.128.0.105/MakEditProxy/WFS-basic.xsd");&lt;BR /&gt; XDocument xDoc1 = new XDocument(new XDeclaration("1.0", "UTF-8", "no"));&lt;BR /&gt; XElement dSigEnvelope = new XElement(new XElement(wfs + "FeatureCollection",&lt;BR /&gt; new XAttribute("xmlns", wfs),&lt;BR /&gt; new XAttribute(XNamespace.Xmlns + "wfs", wfs),&lt;BR /&gt; new XAttribute(XNamespace.Xmlns + "akn", akn),&lt;BR /&gt; new XAttribute(XNamespace.Xmlns + "gml", gml),&lt;BR /&gt; new XAttribute(XNamespace.Xmlns + "xsi", xsi),&lt;BR /&gt; new XAttribute(xsi + "schemaLocation", schemaLocation),&lt;BR /&gt; new XElement(gml + "description", "Geographic Markup Language (GML)"),&lt;BR /&gt; new XElement(gml + "name", "buildings"),&lt;BR /&gt; new XElement(gml + "boundedBy",&lt;BR /&gt; new XElement(gml + "Box",&lt;BR /&gt; new XElement(gml + "coordinates", CoordX.Min() + "," + CoordY.Min() + " " + CoordX.Max() + "," + CoordY.Max())))));&lt;BR /&gt; for (int i = 0; i &amp;lt; _overlay_Graphic.Graphics.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; if (_overlay_Graphic.Graphics&lt;I&gt;.Attributes.Count &amp;gt; 0)&lt;BR /&gt; {&lt;BR /&gt; k = k + 1;&lt;BR /&gt; XElement Polygon = new XElement(gml + "Polygon");&lt;BR /&gt; String str1 = _overlay_Graphic.Graphics&lt;I&gt;.Geometry.ToJson().Replace(@"""PROJCS[\""" + "Bessel_1841_Transverse_Mercator" + @"\"",GEOGCS[\""GCS_Bessel_1841\"",DATUM[\""D_Bessel_1841\"",SPHEROID[\""Bessel_1841\"",6377397.155,299.1528128]],PRIMEM[\""Greenwich\"",0.0],UNIT[\""Degree\"",0.0174532925199433]],PROJECTION[\""Transverse_Mercator\""],PARAMETER[\""False_Easting\"",7500000.0],PARAMETER[\""False_Northing\"",0.0],PARAMETER[\""Central_Meridian\"",21.0],PARAMETER[\""Scale_Factor\"",0.9999],PARAMETER[\""Latitude_Of_Origin\"",0.0],UNIT[\""Meter\"",1.0]]""", "");&lt;BR /&gt; String str2 = str1.Replace("]]]," + @"""spatialReference"":{" + @"""wkt"":", "");&lt;BR /&gt; String str3 = str2.Replace("}}", "");&lt;BR /&gt; String str4 = str3.Replace(@"""x"":", "");&lt;BR /&gt; String str5 = str4.Replace(@",""z"":0", "");&lt;BR /&gt; String str6 = str5.Replace("{" + @"""rings"":[[[", "");&lt;BR /&gt; String str7 = str6.Replace("],[", " ");&lt;BR /&gt; String coordinate = str7.Replace(@"""y"":", "");&lt;BR /&gt; XElement gml1 = new XElement(gml + "featureMember",&lt;BR /&gt; new XElement(akn + "BUILDINGS_TRANS", new XAttribute("fid", "BUILDINGS_TRANS." + k),&lt;BR /&gt; from keyValue in _overlay_Graphic.Graphics&lt;I&gt;.Attributes&lt;BR /&gt; select new XElement(akn + keyValue.Key, keyValue.Value),&lt;BR /&gt; new XElement(akn + "GEOMETRY",&lt;BR /&gt; new XElement(gml + "Polygon",&lt;BR /&gt; new XElement(gml + "outerBoundaryIs",&lt;BR /&gt; new XElement(gml + "LinearRing",&lt;BR /&gt; new XElement(gml + "coordinates", coordinate))))))&lt;BR /&gt; );&lt;BR /&gt; if (GlobalVar.CommandBP == "holeBuilding")&lt;BR /&gt; {&lt;BR /&gt; foreach (KeyValuePair&amp;lt;string, List&amp;lt;String&amp;gt;&amp;gt; item in GlobalVar.InnerBoundBuild)&lt;BR /&gt; {&lt;BR /&gt; if (_overlay_Graphic.Graphics&lt;I&gt;.Attributes["BUILDNO"].ToString() == item.Value[0] &amp;amp;&amp;amp; _overlay_Graphic.Graphics&lt;I&gt;.Attributes["PARCNO"].ToString() == item.Value[1])&lt;BR /&gt; {&lt;BR /&gt; XElement innerBoundaryIs = new XElement(gml + "innerBoundaryIs");&lt;BR /&gt; XElement coordinates1 = new XElement(gml + "coordinates", item.Key);&lt;BR /&gt; XElement LinearRing1 = new XElement(gml + "LinearRing");&lt;BR /&gt; Polygon.Add(innerBoundaryIs);&lt;BR /&gt; innerBoundaryIs.Add(LinearRing1);&lt;BR /&gt; LinearRing1.Add(coordinates1);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; dSigEnvelope.Add(gml1);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; xDoc1.Add(dSigEnvelope);&lt;BR /&gt; if (!File.Exists(tempPath1))&lt;BR /&gt; {&lt;BR /&gt; xDoc1.Save(tempPath1);&lt;BR /&gt; GlobalVar.InnerBoundBuild.Clear();&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; catch&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/J&gt;&lt;/J&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;(Exception ex)&lt;BR /&gt; { MessageBox.Show(ex.ToString()); }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is function for writing to gml file Graphic. Application work OK for writing &amp;nbsp;several graphics to GML. When write &amp;nbsp;more of 100 graphics applications is very slow and may to crash.I know that start garbage collector because in loops&amp;nbsp;have several initialize on XElement constructors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to solved this problem? I would like to have only one initialize for each XElement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 17 Mar 2019 15:25:39 GMT</pubDate>
    <dc:creator>KiroAndreev1</dc:creator>
    <dc:date>2019-03-17T15:25:39Z</dc:date>
    <item>
      <title>Problem with memory when write to GML file</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/problem-with-memory-when-write-to-gml-file/m-p/70591#M306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try&lt;BR /&gt; {&lt;BR /&gt; //Set Folder permission&lt;BR /&gt; SetFullAccessPermissionsForEveryone(Path.GetTempPath());&lt;BR /&gt; string tempPath = Path.Combine(Path.GetTempPath(), "Temp");&lt;BR /&gt; string tempPath1 = Path.Combine(tempPath, "buildings.gml");&lt;/P&gt;&lt;P&gt;if (File.Exists(tempPath1))&lt;BR /&gt; {&lt;BR /&gt; File.Delete(tempPath1);&lt;BR /&gt; }&lt;BR /&gt; List&amp;lt;double&amp;gt; CoordX = new List&amp;lt;double&amp;gt;();&lt;BR /&gt; List&amp;lt;double&amp;gt; CoordY = new List&amp;lt;double&amp;gt;();&lt;BR /&gt; int k = 0;&lt;BR /&gt; &lt;BR /&gt; char[] delimiters = new char[] { ',' };&lt;BR /&gt; for (int i = 0; i &amp;lt; _overlay_Graphic.Graphics.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; if (_overlay_Graphic.Graphics&lt;I&gt;.Attributes.Count &amp;gt; 0)&lt;BR /&gt; {&lt;BR /&gt; var coords = _overlay_Graphic.Graphics&lt;I&gt;.Geometry as Multipart;&lt;BR /&gt; var points = coords.Parts.First().Points;&lt;BR /&gt; for (int j = 0; j &amp;lt; points.Count; j++)&lt;BR /&gt; {&lt;BR /&gt; MapPoint point = new MapPoint(Math.Round(Convert.ToDouble(points&lt;J&gt;.X),2), Math.Round(Convert.ToDouble(points&lt;J&gt;.Y),2), new SpatialReference(WKID));&lt;BR /&gt; MapPoint pointUTM = (MapPoint)GeometryEngine.Project(point, new SpatialReference(WKID));&lt;BR /&gt; CoordX.Add(pointUTM.X);&lt;BR /&gt; CoordY.Add(pointUTM.Y);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; XNamespace akn = "http://www.openplans.org/topp";&lt;BR /&gt; XNamespace wfs = "http://www.opengis.net/wfs";&lt;BR /&gt; XNamespace xs = "http://www.w3.org/2001/XMLSchema";&lt;BR /&gt; XNamespace arec = "http://mak.arec/";&lt;BR /&gt; XNamespace gml = "http://www.opengis.net/gml";&lt;BR /&gt; XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";&lt;BR /&gt; XNamespace schemaLocation = XNamespace.Get("http://www.openplans.org/topp http://128.128.0.105/MakEditProxy/dzgr_parc_trans.xsd http://www.opengis.net/wfs http://128.128.0.105/MakEditProxy/WFS-basic.xsd");&lt;BR /&gt; XDocument xDoc1 = new XDocument(new XDeclaration("1.0", "UTF-8", "no"));&lt;BR /&gt; XElement dSigEnvelope = new XElement(new XElement(wfs + "FeatureCollection",&lt;BR /&gt; new XAttribute("xmlns", wfs),&lt;BR /&gt; new XAttribute(XNamespace.Xmlns + "wfs", wfs),&lt;BR /&gt; new XAttribute(XNamespace.Xmlns + "akn", akn),&lt;BR /&gt; new XAttribute(XNamespace.Xmlns + "gml", gml),&lt;BR /&gt; new XAttribute(XNamespace.Xmlns + "xsi", xsi),&lt;BR /&gt; new XAttribute(xsi + "schemaLocation", schemaLocation),&lt;BR /&gt; new XElement(gml + "description", "Geographic Markup Language (GML)"),&lt;BR /&gt; new XElement(gml + "name", "buildings"),&lt;BR /&gt; new XElement(gml + "boundedBy",&lt;BR /&gt; new XElement(gml + "Box",&lt;BR /&gt; new XElement(gml + "coordinates", CoordX.Min() + "," + CoordY.Min() + " " + CoordX.Max() + "," + CoordY.Max())))));&lt;BR /&gt; for (int i = 0; i &amp;lt; _overlay_Graphic.Graphics.Count; i++)&lt;BR /&gt; {&lt;BR /&gt; if (_overlay_Graphic.Graphics&lt;I&gt;.Attributes.Count &amp;gt; 0)&lt;BR /&gt; {&lt;BR /&gt; k = k + 1;&lt;BR /&gt; XElement Polygon = new XElement(gml + "Polygon");&lt;BR /&gt; String str1 = _overlay_Graphic.Graphics&lt;I&gt;.Geometry.ToJson().Replace(@"""PROJCS[\""" + "Bessel_1841_Transverse_Mercator" + @"\"",GEOGCS[\""GCS_Bessel_1841\"",DATUM[\""D_Bessel_1841\"",SPHEROID[\""Bessel_1841\"",6377397.155,299.1528128]],PRIMEM[\""Greenwich\"",0.0],UNIT[\""Degree\"",0.0174532925199433]],PROJECTION[\""Transverse_Mercator\""],PARAMETER[\""False_Easting\"",7500000.0],PARAMETER[\""False_Northing\"",0.0],PARAMETER[\""Central_Meridian\"",21.0],PARAMETER[\""Scale_Factor\"",0.9999],PARAMETER[\""Latitude_Of_Origin\"",0.0],UNIT[\""Meter\"",1.0]]""", "");&lt;BR /&gt; String str2 = str1.Replace("]]]," + @"""spatialReference"":{" + @"""wkt"":", "");&lt;BR /&gt; String str3 = str2.Replace("}}", "");&lt;BR /&gt; String str4 = str3.Replace(@"""x"":", "");&lt;BR /&gt; String str5 = str4.Replace(@",""z"":0", "");&lt;BR /&gt; String str6 = str5.Replace("{" + @"""rings"":[[[", "");&lt;BR /&gt; String str7 = str6.Replace("],[", " ");&lt;BR /&gt; String coordinate = str7.Replace(@"""y"":", "");&lt;BR /&gt; XElement gml1 = new XElement(gml + "featureMember",&lt;BR /&gt; new XElement(akn + "BUILDINGS_TRANS", new XAttribute("fid", "BUILDINGS_TRANS." + k),&lt;BR /&gt; from keyValue in _overlay_Graphic.Graphics&lt;I&gt;.Attributes&lt;BR /&gt; select new XElement(akn + keyValue.Key, keyValue.Value),&lt;BR /&gt; new XElement(akn + "GEOMETRY",&lt;BR /&gt; new XElement(gml + "Polygon",&lt;BR /&gt; new XElement(gml + "outerBoundaryIs",&lt;BR /&gt; new XElement(gml + "LinearRing",&lt;BR /&gt; new XElement(gml + "coordinates", coordinate))))))&lt;BR /&gt; );&lt;BR /&gt; if (GlobalVar.CommandBP == "holeBuilding")&lt;BR /&gt; {&lt;BR /&gt; foreach (KeyValuePair&amp;lt;string, List&amp;lt;String&amp;gt;&amp;gt; item in GlobalVar.InnerBoundBuild)&lt;BR /&gt; {&lt;BR /&gt; if (_overlay_Graphic.Graphics&lt;I&gt;.Attributes["BUILDNO"].ToString() == item.Value[0] &amp;amp;&amp;amp; _overlay_Graphic.Graphics&lt;I&gt;.Attributes["PARCNO"].ToString() == item.Value[1])&lt;BR /&gt; {&lt;BR /&gt; XElement innerBoundaryIs = new XElement(gml + "innerBoundaryIs");&lt;BR /&gt; XElement coordinates1 = new XElement(gml + "coordinates", item.Key);&lt;BR /&gt; XElement LinearRing1 = new XElement(gml + "LinearRing");&lt;BR /&gt; Polygon.Add(innerBoundaryIs);&lt;BR /&gt; innerBoundaryIs.Add(LinearRing1);&lt;BR /&gt; LinearRing1.Add(coordinates1);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; dSigEnvelope.Add(gml1);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; xDoc1.Add(dSigEnvelope);&lt;BR /&gt; if (!File.Exists(tempPath1))&lt;BR /&gt; {&lt;BR /&gt; xDoc1.Save(tempPath1);&lt;BR /&gt; GlobalVar.InnerBoundBuild.Clear();&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; catch&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/J&gt;&lt;/J&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;(Exception ex)&lt;BR /&gt; { MessageBox.Show(ex.ToString()); }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is function for writing to gml file Graphic. Application work OK for writing &amp;nbsp;several graphics to GML. When write &amp;nbsp;more of 100 graphics applications is very slow and may to crash.I know that start garbage collector because in loops&amp;nbsp;have several initialize on XElement constructors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to solved this problem? I would like to have only one initialize for each XElement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Mar 2019 15:25:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/problem-with-memory-when-write-to-gml-file/m-p/70591#M306</guid>
      <dc:creator>KiroAndreev1</dc:creator>
      <dc:date>2019-03-17T15:25:39Z</dc:date>
    </item>
  </channel>
</rss>

