title: LowProfileImageLoader get OutOfMemoryException Windows Phone
body: <p>I am using LowProfileImageLoader  to load images async without block UI.</p>
  
  <p>You can get it from link: <a href="http://blogs.msdn.com/b/delay/archive/2011/03/03/quot-your-feedback-is-important-to-us-please-stay-on-the-line-quot-improving-windows-phone-7-application-performance-is-even-easier-with-these-lowprofileimageloader-and-deferredloadlistbox-updates.aspx" rel="nofollow">LowProfileImageLoader </a></p>
  
  <p>Everything is OK if DataSource of List has many different links.</p>
  
  <p><strong>But now, I want to test with DataSource with all same URL so In file TwitterService.cs, I edit followed:</strong></p>
  
  <pre><code>private static void HandleGetFollowersResponse(IAsyncResult result)
          {
              var state = (GetFollowersState)result.AsyncState;
  //#if DEBUG
              try
              {
  //#endif
                  //using (var response = state.Request.EndGetResponse(result))
                  //{
                  //    using (var stream = response.GetResponseStream())
                  //    {
                  //        var document = XDocument.Load(stream);
                  //        Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
                  //        {
                  //            foreach (var user in document.Element("users_list").Element("users").Elements("user"))
                  //            {
                  //                state.Collection.Add(new TwitterUser(user.Element("screen_name").Value, new Uri(user.Element("profile_image_url").Value)));
                  //            }
                  //        });
                  //        var nextCursor = document.Element("users_list").Element("next_cursor").Value;
                  //        if ("0" == nextCursor)
                  //        {
                  //            // Load completed
                  //            if (null != state.OnFollowersLoaded)
                  //            {
                  //                Deployment.Current.Dispatcher.BeginInvoke(() =&gt; state.OnFollowersLoaded());
                  //            }
                  //        }
                  //        else
                  //        {
                  //            // Load the next set
                  //            MakeGetFollowersRequest(state.ScreenName, nextCursor, state.Collection, state.OnFollowersLoaded);
                  //        }
                  //    }
                  //}
  
                  throw new WebException();
  //#if DEBUG
              }
              catch (WebException)
              {
                   //No network access; create some fake users for debugging purposes
                  for (var i = 0; i &lt; 200; i++)
                  {
                      state.Collection.Add(new TwitterUser("Fake User " + i, new Uri("http://4.bp.blogspot.com/-O-6vxSiyvbk/UClib6CiR0I/AAAAAAAAQaI/5Fr1dI-kQBI/s1600/Flowers+beauty+desktop+wallpapers.+(1).jpg")));
                  }
                  if (null != state.OnFollowersLoaded)
                  {
                      Deployment.Current.Dispatcher.BeginInvoke(() =&gt; state.OnFollowersLoaded());
                  }
              }
  //#endif
          }
  </code></pre>
  
  <p><strong>It will create dataSource of List with 200 item that has same URL to test.</strong></p>
  
  <p><em><strong>In LowProfileImageLoader.cs, I log the currentUsedMemory of app:</em></strong></p>
  
  <pre><code>private static void WorkerThreadProc(object unused)
      {
              // Process pending completions
                      if (0 &lt; pendingCompletions.Count)
                      {
                          // Get the Dispatcher and process everything that needs to happen on the UI thread in one batch
                          Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
                          {
  
                              while (0 &lt; pendingCompletions.Count)
                              {
  
                                  Logger.printUsedMemory();
                                  }
                              }
                          }
  
      }
  </code></pre>
  
  <p>Logger.printUsedMemory() is helper function to help me log current used memory of my app.
  Nothing edit anymore in code.</p>
  
  <p>But when run my app, the result is strange:
  <strong>I get OutOfMemoryException.</strong></p>
  
  <p><em><strong>Text log in Output windows (used memory in bytes) bellow:</em></strong></p>
  
  <pre><code> Used memory: 21966848
   Used memory: 25051136
   Used memory: 28442624
   Used memory: 32673792
   Used memory: 35512320
   Used memory: 39079936
   Used memory: 43364352
   Used memory: 46571520
   Used memory: 49815552
   Used memory: 53497856
   Used memory: 52514816
   Used memory: 55902208
   Used memory: 60452864
   Used memory: 62001152
   Used memory: 65503232 ~ 65.5mb
   Used memory: 69005312 ~ 69mb
  </code></pre>
  
  <p>Text log show that <strong>after loading image memory increase ~ 3mb</strong> although <strong>image size (from URL) only 120kb.</strong></p>
  
  <p>Why does the OutofMemoryException throws ?
  Why garbage collection not call and my memory increased steady ?</p>
  
  <p>Any help is very apprepriate.
  Thank in advance.</p>