2013-03-11 2 views
0

내 카테고리가 매번 웹에서 제공된 카테고리로 이미지를로드해야하며 작동 중이며 문제는 메모리입니다. 다음 카테고리 이미지가로드되어 메모리가 증가하면 메모리에로드 된 이미지가 제거되지 않습니다. 다음 메시지로 닫는 응용 프로그램 -윈도우 폰 8의 메모리 관리

'[4036] TaskHost.exe'코드가 -2005270523 (0x887a0005)으로 종료되었습니다.

코드는 ---

공극 webClient_DownloadStringCompleted (객체 송신자 DownloadStringCompletedEventArgs E) { 경우 (e.Error = NULL!) { timer.Stop(); 반환; } 목록 rootobj = JsonConvert.DeserializeObject> (e.Result);

 int c = 0, x = 0; 
     for (int i = 0; i < rootobj.Count; i++) 
     { 
      Image img = new Image(); 
      img.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; 
      img.VerticalAlignment = System.Windows.VerticalAlignment.Top; 
      img.Height = 160; 
      img.Width = 210; 
      img.Stretch = System.Windows.Media.Stretch.Fill; 


      BitmapImage bit = new BitmapImage(); 
      string path = rootobj.ElementAt(i).ThumbnailUrl; 
      bit.UriSource = new Uri(path,UriKind.RelativeOrAbsolute); 
      img.Source = bit; 
    img.Margin = new Thickness(x, y, 0, 0); 


      c++; 
      if (c == 2) 
      { 
       x = 0; 
       y = y + 160; 
       c = 0; 
      } 
      else 
      { 
       x = x + 210; 
      } 
      mainGrid.Children.Add(img); 
     } mainGrid.Children.Add(grid); 
     } 

내가 these--

 for (int i = 0; i < rootobj.Count; i++) 
     { 
      Image image = (Image)mainGrid.Children.ElementAt(i); 
      BitmapImage bitmapImage = image.Source as BitmapImage; 
      bitmapImage.UriSource = null; 
      image.Source = null; 
      bitmapImage = null; 
      image = null; 
     } 

     grid.Children.Clear(); 

     mainGrid.Children.Remove(grid); 

을 시도했다하지만 여전히 선택한 이미지의 몇 입력 한 후 충돌 제거합니다. 다음과 같은 작업을 수행 할 수 있습니다

+0

하지만 문제는 무엇인가? – MarcinJuraszek

+0

메모리를 확보하는 방법? – Abhishek

+0

또는로드 된 이미지를 메모리에서 제거하는 방법? – Abhishek

답변

0

:

grid1.Children.Remove(image1); 
image1 = null; 
+0

나는 그리드와 다른 그리드의 그리드에 이미지를 추가했습니다. 내가 사용했던 grid_Children.Clear(); mainGrid.Children.Remove (grid); 하지만 여전히 메모리가 증가하고 있습니다 .. – Abhishek

+0

이미지 객체를 null로 설정 했습니까? –

+0

grid.children.clear() 일부 메모리를 비우면 모든 이미지와 비트 맵 로컬 객체를 단계별로 제거해야합니까? – Abhishek