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

Memory leak detected by LeakCanary #192

Closed
rockerhieu opened this issue May 18, 2015 · 13 comments
Closed

Memory leak detected by LeakCanary #192

rockerhieu opened this issue May 18, 2015 · 13 comments

Comments

@rockerhieu
Copy link

Since stetho isn't available for release version, I think we're fine. But memory leak is memory leak and I think we should eliminate it:

05-19 01:50:00.596  30932-31353/com.company.app D/LeakCanary﹕ * android.content.ContentResolver$CursorWrapperInner (ChatRoomsFragment's cursor) has leaked:
05-19 01:50:00.596  30932-31353/com.company.app D/LeakCanary﹕ * GC ROOT static com.facebook.stetho.inspector.elements.android.ActivityTracker.sInstance
05-19 01:50:00.596  30932-31353/com.company.app D/LeakCanary﹕ * references com.facebook.stetho.inspector.elements.android.ActivityTracker.mActivities
05-19 01:50:00.596  30932-31353/com.company.app D/LeakCanary﹕ * references java.util.ArrayList.array
05-19 01:50:00.596  30932-31353/com.company.app D/LeakCanary﹕ * references array java.lang.Object[].[0]
...
@jasta
Copy link
Contributor

jasta commented May 19, 2015

Err, I haven't personally checked out LeakCanary but I'm willing to bet this is either a false positive or representative of a different kind of bug. ActivityTracker is designed to keep a strong reference to all activities that were not destroyed so that they can be "seen" by Stetho. When you destroy the activity, however, it should definitely be removed. If that's not the case then the leak is legitimate, but I doubt that's true nominally given that we trust the Android framework itself to tell us when the removal occurs.

@edward-s
Copy link

im getting the same leak in leakcanary also
GC ROOT static com.facebook.stetho.inspector.elements.android.ActivityTracker.sInstance

any way to fix this?

@155martinmoreno
Copy link

me too... is eating 50k per second of memory

@jasta
Copy link
Contributor

jasta commented Jun 11, 2015 via email

@laoda512
Copy link

I found the same question too. Although GC will release such memory, it's strange to see allocated memory increase every second...

@jasta
Copy link
Contributor

jasta commented Jul 10, 2015

FWIW, I still can't repro this and have no concrete information on which to operate. Can anyone provide some details here? What is leaking? What is it's path to the GC root? Why do you believe it should have been released?

@rickbrew
Copy link
Contributor

And which version of Android is it happening on?

@Actine
Copy link

Actine commented Jul 23, 2015

+1. Noticed my memory was being eaten up, quick allocation dump identified Stetho was a culprit

image

Take a look at your networking logic. Looks like it keeps allocating new stream buffers around com.facebook.stetho.server.LocalSocketHttpServerConnection.LocalSocketSessionInputBuffer / ...OutputBuffer. It's not a memory leak (it indeed gets GC'd), but slow memory churn.

@jasta
Copy link
Contributor

jasta commented Jul 23, 2015 via email

@Actine
Copy link

Actine commented Jul 23, 2015

@jasta well, the alllocation dump was taken over the course of roughly 1 second of the app being idle, and there were 6 allocations of 12KiB buffers, all coming from LocalSocketHttpServerConnection.bind(). This is regardless whether I am currently connected via chrome tools or not. It feels like three 12KiB buffers get allocated each second and then thrown away to be GC'ed. Again, this is not memory leak, but nonetheless IMHO this should not be happening, as buffers by definition should be flushed and reused rather than thrown away. Not mentioning that this is messing with profiling the rest of the app.

P.S. In fact I am not sure if this is related to the reported "memory leak" issue and whatever LeakCanary reports, but judging from the comments my symptoms were similar so I didn't open a new issue. Maybe this is a different issue.

@jasta
Copy link
Contributor

jasta commented Jul 23, 2015 via email

@Actine
Copy link

Actine commented Jul 23, 2015

@jasta Oh, you're right. Sorry then :)

@jasta
Copy link
Contributor

jasta commented Aug 10, 2015

Unable to repro, closing...

@jasta jasta closed this as completed Aug 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants