DingMouRen / LayoutManagerGroup

:point_right: Customize the LayoutManager of RecyclerView(自定义LayoutManager)
4.98k stars 679 forks source link

会内存溢出 #5

Closed huangfen closed 6 years ago

huangfen commented 6 years ago

java.lang.OutOfMemoryError: Failed to allocate a 960012 byte allocation with 225520 free bytes and 220KB until OOM

at com.dingmouren.example.layoutmanagergroup.activity.SkidRightActivity_1$MyAdapter.onBindViewHolder(SkidRightActivity_1.java:89) at com.dingmouren.example.layoutmanagergroup.activity.SkidRightActivity_1$MyAdapter.onBindViewHolder(SkidRightActivity_1.java:68)

DingMouRen commented 6 years ago

@huangfen 内存溢出的原因 1.这个实例加载的是高清的gif 2.你的手机内存有点低 3.SkidRightLayoutManager只是负责排列,你加载的资源占用内存大自然会内存溢出,内存溢出需要你自己在加载资源的时候处理

yhzhan1002 commented 6 years ago

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.dingmouren.example.layoutmanagergroup, PID: 4512 java.lang.OutOfMemoryError: Failed to allocate a 721592 byte allocation with 214608 free bytes and 209KB until OOM at com.bumptech.glide.gifdecoder.GifDecoder.setData(GifDecoder.java:380) at com.bumptech.glide.load.resource.gif.GifDrawable.(GifDrawable.java:92) at com.bumptech.glide.load.resource.gif.GifDrawable$GifState.newDrawable(GifDrawable.java:368) at com.bumptech.glide.load.resource.drawable.DrawableResource.get(DrawableResource.java:32) at com.bumptech.glide.load.resource.drawable.DrawableResource.get(DrawableResource.java:16) at com.bumptech.glide.load.engine.EngineResource.get(EngineResource.java:44) at com.bumptech.glide.request.GenericRequest.onResourceReady(GenericRequest.java:487) at com.bumptech.glide.load.engine.Engine.load(Engine.java:155) at com.bumptech.glide.request.GenericRequest.onSizeReady(GenericRequest.java:449) at com.bumptech.glide.request.target.ViewTarget$SizeDeterminer.getSize(ViewTarget.java:211) at com.bumptech.glide.request.target.ViewTarget.getSize(ViewTarget.java:100) at com.bumptech.glide.request.GenericRequest.begin(GenericRequest.java:272) at com.bumptech.glide.manager.RequestTracker.runRequest(RequestTracker.java:37) at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:661) at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:697) at com.dingmouren.example.layoutmanagergroup.activity.SkidRightActivity_1$MyAdapter.onBindViewHolder(SkidRightActivity_1.java:89) at com.dingmouren.example.layoutmanagergroup.activity.SkidRightActivity_1$MyAdapter.onBindViewHolder(SkidRightActivity_1.java:68) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6482) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6515) at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5458) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5724) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5563) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5559) at com.dingmouren.layoutmanagergroup.skidright.SkidRightLayoutManager.fill(SkidRightLayoutManager.java:128) at com.dingmouren.layoutmanagergroup.skidright.SkidRightLayoutManager.scrollHorizontallyBy(SkidRightLayoutManager.java:163) at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4834) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920) at android.view.Choreographer.doCallbacks(Choreographer.java:695) at android.view.Choreographer.doFrame(Choreographer.java:628) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7225) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)