Memory leaks in Android applications in general
Are you sure this is a memory leak, not just a delay in garbage collection? Have you, for example, launched the eclipse memory analyzer plugin in an application? It can often show where the leak occurs.
In the mode of viewing a fragment and its disposal (or its absence)
My first assumption of memory leak / enlargement in the pager fragments has a dynamic adapter. The fragmentpageradapter is pretty dumb and will not handle changes well .
As far as I can see from the source, it will never destroy fragments, even if, for example, you change the count from 5 to 4 (the fifth fragment will remain in the fragment manager). This is due to the fact that it is removed, and not destroyed. fragstatepageradapter , however, will destroy views if they are outside the page margin.
And all this does not actually lead to memory leaks in the end, because these fragments will be cleared when the fragmenter is cleared of fragments later. However, it can slightly increase memory usage (potentially leading to outofmemoryerror).
A new view is created each time a fragment is created (and more often than when keepinstance is set to true), but if you do not use the FragmentStatePagerAdapter, which should appear only once per fragment, since a normal pager adapter disconnects and attaches the same fragments from the manager fragments. And in any case, the view will be deleted after the action is destroyed, if you do not save links to it.
It seems that you keep references to representations in your class, which I usually try to avoid. I prefer to use getView (). FindViewById () when I need them, but in this case, I think that member references should be found and removed by gc. It all depends on whether you have comforted these links elsewhere.
In the viewport in the fragment player
You should not try to do something like a viewer in a fragment. In this example, this probably won't hurt, but I donβt see you getting anything from him. Just inflate the view in oncreateview and set the values ββand do with it.
There is no reprocessing of views in the list, so the ViewHolder template does not make sense and there are only risks associated with a memory leak or delayed garbage collection due to freezing links.
Views are not intended to be reused, even if they might be during any of the original tricks you used. This should be done only as a final exit. If nothing happens in the stream, this can lead to terrible leaks.
Please correct me if anyone can see reasonable use.
ViewHolder Side Note
I would really refrain from using the viewer if I really didn't need him even on the list. I saw that these tags lead to really nasty memory leaks, like some cursor adapters, for example, and I would look to make my line layouts easier before trying to save links. Findviewbyid will not be so expensive in a good layout.