msayan / tutorial-view

Android Tutorial View
MIT License
251 stars 58 forks source link

OutOfMemoryError with 10 png drawables #9

Closed alexmelyon closed 5 years ago

alexmelyon commented 5 years ago

Crashed on Genymotion Nexus 4 version 5.0 api 21. Library v1.0.8.

    --------- beginning of crash
04-05 00:07:13.291 12931-12931/com.helloandroid E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.helloandroid, PID: 12931
    java.lang.OutOfMemoryError: Failed to allocate a 15728652 byte allocation with 3872544 free bytes and 3MB until OOM
        at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
        at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
        at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:973)
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2423)
        at android.content.res.Resources.loadDrawable(Resources.java:2330)
        at android.content.res.Resources.getDrawable(Resources.java:758)
        at android.content.Context.getDrawable(Context.java:402)
        at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:358)
        at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
        at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
        at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
        at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:85)
        at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:93)
        at com.hololo.tutorial.library.StepFragment.initData(StepFragment.java:59)
        at com.hololo.tutorial.library.StepFragment.onCreateView(StepFragment.java:43)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2346)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1428)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827)
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2596)
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2383)
        at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2338)
        at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2215)
        at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:649)
        at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1238)
        at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:663)
        at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:625)
        at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:617)
        at com.hololo.tutorial.library.TutorialActivity.changeFragment(TutorialActivity.java:241)
        at com.hololo.tutorial.library.TutorialActivity.onClick(TutorialActivity.java:203)
        at android.view.View.performClick(View.java:4756)
        at android.view.View$PerformClick.run(View.java:19749)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

How can I fix this error? Any unload method or bitmap options? 10 PNG images from 23362 to 71362 bytes. 768x1280px. Crashed on 6th.

msayan commented 5 years ago

Hi @alexmelyon , This issue should fixed with version v1.0.10 Can you try it?

alexmelyon commented 5 years ago

@msayan I have tested v1.0.10, but behaviour is the same. Crashed on 6th image.

msayan commented 5 years ago

Hi @alexmelyon, I can not reproduce the issue. Can you share your activity and resources with me?

alexmelyon commented 5 years ago

@msayan Here https://github.com/alexmelyon/Master-Charlist/ Branch msayan_reproduce_oom

msayan commented 5 years ago

Hello @alexmelyon , Your problem should be fixed in v1.0.11

alexmelyon commented 5 years ago

@msayan Thanks. No crash now.