2

저는 Android 개발 초보자입니다. 내 애플 리케이션에 몇 가지 화면이 있으며 "backstack"기능을 사용하여이 화면을 앞뒤로 탐색 할 수 있습니다. 앱을 깊이 훑어 가면서 앱의 메모리 사용량이 증가하고 있습니다. 때로는 최대 100MB까지 도달합니다 .. !! 앱이 다시 시작됩니다.Android, 메모리 과용 문제

내가 알고있는 것처럼, 아래 수 있으며, 메모리 남용 뒤에 가능한 이유 :

1) 응용 프로그램은 이미지를 많이 사용합니다.

2) 백 스택이 구현됩니다. (사용 된 활동은 단 한 번뿐입니다.)

3) 해당 응용 프로그램에 대해 하나의 백그라운드 서비스가 계속 실행 중입니다.

이것이 실제 이유인지는 확실하지 않습니다. 이유를 찾도록 도와주세요. 메모리 과용 문제에 관한 팁? 또 하나의 질문 : 안드로이드 앱의 이상적인 메모리 사용은 무엇이되어야합니까? http://stackoverflow.com/questions :

+0

에서 추락하지 않습니다 이들에 대해 살펴/21795645/exception-outofmemoryerror/21950787 # 21950787 및 http://stackoverflow.com/questions/22043232/out-of-memory-exception-with-custom-gridview/22043466#22043466 및 그 안에있는 링크 – user2450263

답변

0

통화는 안드로이드 데이터와 UR 응용 프로그램에서 이미지의 모든 캐시를 삭제 앱에서이 방법은 메모리 문제

//this is for clear cache folder in android -> data folder which generate by gallry lazy loading 
     public static void trimCache(Context context) { 
      try { 
    //   File dir = context.getCacheDir(); 
       File dir = context.getExternalCacheDir(); 
       if (dir != null && dir.isDirectory()) { 
        deleteDir(dir); 
        System.out.println("delete cache folderrrrrrrrrr"); 
       } 
      } catch (Exception e) { 
       // TODO: handle exception 
      } 
     } 
     public static void trimCacheinternal(Context context) { 
      try { 
       File dir = context.getCacheDir(); 
    //   File dir = context.getExternalCacheDir(); 
       if (dir != null && dir.isDirectory()) { 
        deleteDir(dir); 
        System.out.println("delete cache folderrrrrrrrrr"); 
       } 
      } catch (Exception e) { 
       // TODO: handle exception 
      } 
     }