2013-03-28 2 views
0

내 응용 프로그램에서 .txt 파일을 사용하여 geopoints 및 문자열을 저장하므로 .txt에서 줄 바꿈을 삭제하는 대신 삭제할 수 있습니다. 행. 그래서 데이터 저장만을위한 테스트에 넣었습니다. 그러나 데이터를로드 할 때 96x96 파일을 디코딩하는 비트 맵에서 메모리 부족 오류가 발생했습니다. 이는 나에게 의미가 없습니다. .txt 파일 대신 SQLite를 사용하면 OutOfMemory 오류가 발생합니다.

는 로그 캣입니다 : 내가 발견

03-28 09:48:30.059: E/dalvikvm-heap(4607): Out of memory on a 46096-byte allocation. 
03-28 09:48:30.059: I/dalvikvm(4607): "main" prio=5 tid=1 RUNNABLE 
03-28 09:48:30.059: I/dalvikvm(4607): | group="main" sCount=0 dsCount=0 obj=0x40a719a0 self=0x2a00bba8 
03-28 09:48:30.059: I/dalvikvm(4607): | sysTid=4607 nice=0 sched=0/0 cgrp=apps handle=1073849308 
03-28 09:48:30.070: I/dalvikvm(4607): | state=R schedstat=(9701142608 17839341793 3050) utm=828 stm=142 core=0 
03-28 09:48:30.070: I/dalvikvm(4607): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 
03-28 09:48:30.070: I/dalvikvm(4607): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:529) 
03-28 09:48:30.070: I/dalvikvm(4607): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:302) 
03-28 09:48:30.070: I/dalvikvm(4607): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:328) 
03-28 09:48:30.070: I/dalvikvm(4607): at com.apps.gonefishing.Information.onCreate(Information.java:80) 
03-28 09:48:30.070: I/dalvikvm(4607): at android.app.Activity.performCreate(Activity.java:5104) 
03-28 09:48:30.070: I/dalvikvm(4607): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 
03-28 09:48:30.070: I/dalvikvm(4607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 
03-28 09:48:30.070: I/dalvikvm(4607): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
03-28 09:48:30.081: I/dalvikvm(4607): at android.app.ActivityThread.access$600(ActivityThread.java:141) 
03-28 09:48:30.081: I/dalvikvm(4607): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
03-28 09:48:30.090: I/dalvikvm(4607): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-28 09:48:30.090: I/dalvikvm(4607): at android.os.Looper.loop(Looper.java:137) 
03-28 09:48:30.090: I/dalvikvm(4607): at android.app.ActivityThread.main(ActivityThread.java:5039) 
03-28 09:48:30.090: I/dalvikvm(4607): at java.lang.reflect.Method.invokeNative(Native Method) 
03-28 09:48:30.090: I/dalvikvm(4607): at java.lang.reflect.Method.invoke(Method.java:511) 
03-28 09:48:30.090: I/dalvikvm(4607): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
03-28 09:48:30.090: I/dalvikvm(4607): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
03-28 09:48:30.090: I/dalvikvm(4607): at dalvik.system.NativeStart.main(Native Method) 
03-28 09:48:30.110: D/skia(4607): --- decoder->decode returned false 
03-28 09:48:30.110: D/AndroidRuntime(4607): Shutting down VM 
03-28 09:48:30.110: W/dalvikvm(4607): threadid=1: thread exiting with uncaught exception (group=0x40a70930) 
03-28 09:48:30.140: E/AndroidRuntime(4607): FATAL EXCEPTION: main 
03-28 09:48:30.140: E/AndroidRuntime(4607): java.lang.OutOfMemoryError 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:529) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:302) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:328) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at com.apps.gonefishing.Information.onCreate(Information.java:80) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.app.Activity.performCreate(Activity.java:5104) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.app.ActivityThread.access$600(ActivityThread.java:141) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.os.Handler.dispatchMessage(Handler.java:99) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.os.Looper.loop(Looper.java:137) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at android.app.ActivityThread.main(ActivityThread.java:5039) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at java.lang.reflect.Method.invokeNative(Native Method) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at java.lang.reflect.Method.invoke(Method.java:511) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
03-28 09:48:30.140: E/AndroidRuntime(4607):  at dalvik.system.NativeStart.main(Native Method) 

한 가지 힙 메시지가 나오는 모든 시간 만 5~6% 사용할 수있다, 그래서 데이터를 닦아 에뮬레이터를 시작한다는 것입니다 그리고 그것은이다 같은 것. 이것은 응용 프로그램이 텍스트 파일과 함께 실행되었을 때 완벽하게 실행되는 API 17 에뮬레이터입니다.

내가 시도하려고하는 것은 다음과 같습니다.

db = dbHelper.getWritableDatabase(); 

그래서 getReadableDatabase

그것은 변화의 정도 아니다에이 하나 앞에있는 활동에 변경거야 : 나는 데이터베이스를 열 경우에도 내가 사용 읽기 오류와 함께, 그것은 끝나고 모든 것. TextWatcher의 캔버스에서 서로에게 2 개의 비트 맵이 앞뒤로 보내집니다. 나는 그것이 320X480이 .txt 파일로 잘 돌아가는 2 비트 맵 메모리를 필요로한다고 생각한다.

아무런 조언을 주시면 대단히 감사합니다.

Cursor cursor; 
     db.read(); 
     cursor = db.getAllEntries(); 
     boolean go = cursor.moveToFirst(); 
     while(cursor.isAfterLast() != true){ 
      Drawable imagebig = null; 
      Bitmap photobig = null; 
      int lat = cursor.getInt(MyDBAdapter.LATITUDE_COLUMN); 
      int lng = cursor.getInt(MyDBAdapter.LONGITUDE_COLUMN); 
      GeoPoint recall = new GeoPoint(lat,lng); 
      File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Gone"); 
      file = new File(file.getPath(),"Thumbs"); 
      String string = cursor.getString(MyDBAdapter.FILE_COLUMN); 
      File file1 = new File(file.getPath() + File.separator + "thumb" + string); 

      Uri uri = Uri.fromFile(file1); 
      if(file1.exists()){ 
      //photobig = BitmapFactory.decodeFile(file1.getAbsolutePath()); 
      uri = Uri.fromFile(file1); 

      try { 
       photobig = MediaStore.Images.Media.getBitmap(getContentResolver(), uri); 
      } catch (FileNotFoundException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } catch (IOException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 


     } 
     db.close(); 
     cursor.close(); 
+1

의심의 여지가 귀하의 데이터베이스와 관련이 있습니다. –

+0

아이디어가 있습니까? 여기 좀 우둔한 애플 리케이션이 완벽하게 도망쳐서 sqlite로만 .txt 파일을 전환하면 충돌이 시작됩니다. – JRowan

+0

내 gps 수신기를 닫고 있습니다. 정적 비트 맵이 없습니다. – JRowan

답변

3

루프가 무한대입니다. 커서를 앞으로 나아갈 필요가 있습니다.

cursor.moveToNext()를 추가하십시오. while 루프에.

0

그리고 그것은 아파

while(!cursor.isAfterLast()){ 

while(cursor.isAfterLast() != true){ 

을 변경합니다. * 나쁜 방식으로 받아들이지 마십시오.