title: Windows phone app running out of memory
body: <p>Currently my view binds to data in the code behind, in order to display a pic, with 2 subheadings, inside a listbox. however the Windows Phone runs out of memory when I load to much records. I have already made the app to only load 10 records at a time, so when the user scrolls down, 10 more are load etc. But the problem is the phone still runs out of memory when the user loads 200 or more records, and there is about 2600 records. </p>
  
  <pre><code>  &lt;ListBox x:Name="geklassifisseerd_list" 
                           VerticalAlignment="Top"
                           ItemsSource="{Binding ClassifiedAds}"
                           SelectionChanged="geklassifisseerd_list_SelectionChanged_1"
                           Grid.Row="1"&gt;
                      &lt;ListBox.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;StackPanel Margin="5"&gt;
                                  &lt;Image Source="{Binding ImageUrl}" 
                                     Height="140"
                                     Width="160"/&gt;
  
                                  &lt;TextBlock Text="{Binding Title}" 
                                         TextWrapping="Wrap" 
                                         Margin="2" 
                                         Width="160"
                                         Foreground="Black"
                                         FontWeight="Bold"
                                         FontSize="15"/&gt;
  
                                  &lt;TextBlock Text="{Binding CreationDate}" 
                                         TextWrapping="Wrap" 
                                         Foreground="Black"
                                         Margin="2,0,0,5" 
                                         FontSize="13"/&gt;
                              &lt;/StackPanel&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ListBox.ItemTemplate&gt;
  
                      &lt;ItemsControl.ItemsPanel&gt;
                          &lt;ItemsPanelTemplate&gt;
                              &lt;Controls:WrapPanel Orientation="Horizontal"  /&gt;
                          &lt;/ItemsPanelTemplate&gt;
                      &lt;/ItemsControl.ItemsPanel&gt;
  </code></pre>
  
  <p>the Model :</p>
  
  <pre><code> public class ClassifiedAds : INotifyPropertyChanged
  {
      public int ID { get; set; }
      public string Title { get; set; }
  
      private string _body;
      public string Body
      {
          get { return _body; }
          set { _body = HTMLHelper.ConvertHtmlToText(value); }
      }
  
      public string CategoryName { get; set; }
      public string ContactEmail { get; set; }
      public string ContactTel { get; set; }
      public DateTime CreationDate { get; set; }
      public DateTime DisplayUntilDate { get; set; }
      public Gal Gallery { get; set; }
      public string ImageUrl { get; set; }
      public bool IsActive { get; set; }
      public bool IsDeleted { get; set; }
      public DateTime LastUpdateDate { get; set; }
      public string PhysicalAddress { get; set; }
      public string Price { get; set; }
      public string ProvinceName { get; set; }
      public int TotalViews { get; set; }
  
      public event PropertyChangedEventHandler PropertyChanged;
  
      private void RaisePropertyChanged(string propertyName)
      {
          if (this.PropertyChanged != null)
          {
              this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  }
  </code></pre>
  
  <p>I don't know how else I can load the data, since all the records need to be shown, is it possible to unload the previous records as the user scrolls down? or maybe something else I could try?</p>