c# - OutOfMemoryException in Windows Phone app -


i make gallery in app

when , choose album system.outofmemoryexception occurs

this xaml

   <grid x:name="contentpanel" grid.row="1" margin="12,0,12,0">         <scrollviewer margin="0,1,0,71" >             <grid width="475"  name="picbtn" background="whitesmoke" >              </grid>         </scrollviewer>     </grid> 

this code

     string type;     int x = 0;     int y = 4050;     int = 0;     protected override void onnavigatedto(system.windows.navigation.navigationeventargs e)     {         base.onnavigatedto(e);          if (e.navigationmode != navigationmode.back)         {             type = navigationcontext.querystring["name"];              readfromxml(type);         }     }     private void readfromxml(string type)     {          xdocument xml;         if (type == "day")         {             xml = xdocument.load("dayimagesdata.xml");         }         else         {             xml = xdocument.load("nightmagesdata.xml");         }          var query = c in xml.root.descendants("posts")                      select c.element("image").value;         foreach (var name in query)         {               creategrid(name);             i++;             if (i % 3 == 0)             {                 x += 150;                 y -= 150;             }         }      }     private void creategrid(string data)     {          bitmapimage image = new bitmapimage(                 new uri(@"images\" + data, urikind.relative)                 );         grid g1 = new grid         {             width = 150,             height = 150,             margin = new thickness(0, x, 0, y),             datacontext = data          };         image im = new image         {              source = image         };         g1.children.add(im);         if (i % 3 == 0)         { g1.horizontalalignment = system.windows.horizontalalignment.left; }         else if (i % 3 == 1)         {             g1.horizontalalignment = system.windows.horizontalalignment.center;         }         else         {             g1.horizontalalignment = system.windows.horizontalalignment.right;         }          picbtn.children.add(g1);         g1.tap += grid_tap;     } 

is there method clear memory when clicked ?? try gc.collect same issue happened

dispose xdocument , bitmapimage .from code memory consumers on high note.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -