c# - Out of Memory Exception when loading large number of images through a file picker -


windows phone 8.1:

foreach (storagefile file in imagefiles)             {                  classforfolderimages cffi = new classforfolderimages();                 using(var stream = await file.openasync(windows.storage.fileaccessmode.read))                 {                  var bitmapimage = new windows.ui.xaml.media.imaging.bitmapimage();                   bitmapimage.decodepixelwidth = 80;                  bitmapimage.decodepixelheight = 80;                  await bitmapimage.setsourceasync(stream);                   cffi.imageforfolder = bitmapimage;                   gridviewname.add(cffi);                 }             } 

in above snippet "imagefiles" contains large number of images , "gridviewname" name of observable collection later bind grid view wish display these images. classforfolderimages class below:

public class classforfolderimages : inotifypropertychanged {     public event propertychangedeventhandler propertychanged;       private bitmapimage img;      public bitmapimage imageforfolder     {         { return img; }          set         {             img = value;             firepropertychangedevent("imageforfolder");         }     }       public classforfolderimages()     {      }      private void firepropertychangedevent(string propertyname)     {          if (propertychanged != null)             propertychanged(this, new propertychangedeventargs(propertyname));      }  } 

this snippet works fine in phone simulator , small number of images on device ,but on device - number of images increase @ point starts throwing below error (it breaks @ app.g.i.cs) :

exception = function evaluation disabled because of out of memory exception. handled = function evaluation disabled because of out of memory exception. message = function evaluation disabled because of out of memory exception. 

can suggest changes overcome problem?


Comments

Popular posts from this blog

javascript - Wordpress slider, not displayed 100% width -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -