when I new a fragment in an Activity, then I using the profiler to analyse the heap, stay in the current activity. but I got a leak warning which showed a fragment is leaked, is this a bug in profiler? the following picture is the capture
private val f = Fragment()
I thought that the lifecycle of this fragment is shorter or equal than the activity, how can I get the leak?
when I new a fragment in an Activity, then I using the profiler to analyse the heap, stay in the current activity. but I got a leak warning which showed a fragment is leaked, is this a bug in profiler? the following picture is the capture
private val f = Fragment()
I thought that the lifecycle of this fragment is shorter or equal than the activity, how can I get the leak?
Share Improve this question asked Mar 17 at 13:41 ahsiuahsiu 1231 silver badge6 bronze badges 1- I found some explains about this issue developer.android/studio/profile/… – ahsiu Commented Mar 17 at 17:06
1 Answer
Reset to default 0If you create a fragment without adding it to the activity using the fragment transaction manager it will show up as a false positive.
Found here:
https://developer.android/studio/profile/capture-heap-dump#find-memory-leaks