Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StrictMode: resources leak (glide 4 with okhttp integration) #2236

Closed
ikarsokolov opened this issue Aug 11, 2017 · 2 comments
Closed

StrictMode: resources leak (glide 4 with okhttp integration) #2236

ikarsokolov opened this issue Aug 11, 2017 · 2 comments
Labels

Comments

@ikarsokolov
Copy link

ikarsokolov commented Aug 11, 2017

Glide Version: 4.0.0.
Integration libraries: okhttp3-integration

I am experiencing strict mode crashes both on emulator and real devices on Android versions from 4.2 to 7.1. Issue looks similar to now closed ticket #1996.

E/StrictMode: A resource was acquired at attached stack trace but never released.
See java.io.Closeable for information on avoiding resource leaks.
     java.lang.Throwable: Explicit termination method 'response.body().close()' not called
         at dalvik.system.CloseGuard.open(CloseGuard.java:184)
         at java.lang.reflect.Method.invokeNative(Native Method)
         at java.lang.reflect.Method.invoke(Method.java:525)
         at okhttp3.internal.platform.AndroidPlatform$CloseGuard.createAndOpen(AndroidPlatform.java:272)
         at okhttp3.internal.platform.AndroidPlatform.getStackTraceForCloseable(AndroidPlatform.java:138)
         at okhttp3.RealCall.captureCallStackTrace(RealCall.java:78)
         at okhttp3.RealCall.enqueue(RealCall.java:87)
         at com.bumptech.glide.integration.okhttp3.OkHttpStreamFetcher.loadData(OkHttpStreamFetcher.java:45)
         at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
         at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:282)
         at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:252)
         at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:222)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
         at java.lang.Thread.run(Thread.java:841)
         at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:347)

This happens a lot when fast-scrolling recycler view.
My RecyclerView.Adapter is simple:

final GlideRequests glideRequests = GlideApp.with(fragment);
// glideRequests is instance variable of adapter

@Override
public void onBindViewHolder(final ProductViewHolder holder, final int position) {
    glideRequests.asBitmap()
                 .priority(Priority.NORMAL)
                 .diskCacheStrategy(DiskCacheStrategy.ALL)
                 .centerCrop()
                 .thumbnail(0.25f)
                 .placeholder(R.drawable.placeholder)
                 .load(product)
                 .into(holder.cover);
}

@Override
public void onViewRecycled(final ProductViewHolder holder) {
     super.onViewRecycled(holder);
     glideRequests.clear(holder.cover);
}
@rubengees
Copy link

rubengees commented Aug 11, 2017

I am also still experiencing this from time to time with 4.1.0. The load lines and other configs are like in my original issue (#1996).

@sjudd
Copy link
Collaborator

sjudd commented Sep 6, 2017

Duplicate of #1996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants