2017-01-03 10 views
-1

우리는 최근에 FragmentActivity 대신 AppCompatActivity를 사용하도록 전환했으며 일부 장치는 다음 오류로 무작위로 충돌합니다. 왜 이런 일이 일어나는지는 알 수 없습니다.메모리 부족 : android.support.v7.app.AppCompatActivity.onCreate

Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 16008012 byte allocation with 4277152 free bytes and 4MB until OOM 
    at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java) 
    at android.graphics.BitmapFactory.nativeDecodeAsset(BitmapFactory.java) 
    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:856) 
    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:675) 
    at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:703) 
    at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:733) 
    at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:779) 
    at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:741) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:2549) 
    at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:254) 
    at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:164) 
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:2549) 
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:2320) 
    at android.content.res.Resources.loadDrawableForCookie(Resources.java:4210) 
    at android.content.res.Resources.loadDrawable(Resources.java:4089) 
    at android.content.res.Resources.getDrawable(Resources.java:2005) 
    at android.content.res.Resources.getDrawable(Resources.java:1987) 
    at android.content.Context.getDrawable(Context.java:464) 
    at android.support.v4.content.ContextCompat.android.support.v4.content.ContextCompatApi21.getDrawable(SourceFile:3026) 
    at android.support.v7.widget.AppCompatDrawableManager.getDrawable(SourceFile:200) 
    at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(SourceFile:81) 
    at android.support.v7.app.AppCompatDelegateImplBase.(SourceFile:127) 
    at android.support.v7.app.AppCompatDelegateImplV9.(SourceFile:147) 
    at android.support.v7.app.AppCompatDelegateImplV11.(SourceFile:27) 
    at android.support.v7.app.AppCompatDelegateImplV14.(SourceFile:53) 
    at android.support.v7.app.AppCompatDelegateImplV23.(SourceFile:29) 
    at android.support.v7.app.AppCompatDelegate.create(SourceFile:203) 
    at android.support.v7.app.AppCompatDelegate.create(SourceFile:185) 
    at android.support.v7.app.AppCompatActivity.getDelegate(SourceFile:525) 
    at android.support.v7.app.AppCompatActivity.onCreate(SourceFile:74) 
    at com.dubizzle.horizontal.activities.AbstractActivity.onCreate(SourceFile:98) 
    at com.dubizzle.horizontal.activities.ItemPhotoViewer.onCreate(SourceFile:68) 
    at android.app.Activity.performCreate(Activity.java:6876) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) 
    at android.app.ActivityThread.access$1100(ActivityThread.java:222) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:158) 
    at android.app.ActivityThread.main(ActivityThread.java:7229) 
    at java.lang.reflect.Method.invoke(Method.java) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
+2

당신이 @TapanHP 당신이로드하려는 파일이 – TapanHP

+0

쇼 com.dubizzle.horizontal.activities.AbstractActivity.onCreate''의 코드는'com.dubizzle.horizontal.activities.ItemPhotoViewer.onCreate' – Divers

+0

큰 때문입니다 나쁜 조언 제공 – Divers

답변

3

BitmapFactory 권한을 사용하여 이미지를로드하려고합니까? 4277152 무료 바이트

16008012 바이트 할당을 4MB의 이미지가 16,008,012하지만 당신은 무료로 4,277,152 바이트가 OOM

까지 :

나는 당신의 이미지가 너무 큰 것으로 가정합니다. 작은 이미지를 사용해보세요.

+0

응답 해 주셔서 감사합니다. 그러나 AppCompatActivity로 전환 한 후에 만 ​​시작된 이유는 무엇입니까? 또한 특정 화면에 이미지 갤러리가 있으며 사진은 picasso를 사용하여 웹에서로드됩니다. –