2

Say I have a Fragment and in my Fragment I do this:

resultAdapter = new ResultAdapter(this, search);
listView.setAdapter(resultAdapter);

and the constructor of my adapter is:

public ResultAdapter(Fragment fragment) {
    this.fragment = fragment; 
}

My Fragment then holds a reference to the adapter and the adapter holds a reference to the fragment. Would this prevent the GC to collect both om them?

fweigl
  • 21,278
  • 20
  • 114
  • 205

1 Answers1

6

No it wouldn't. When your fragment will be detached from activity and destroyed it will lost reference to the GC root. So it's definitely ok.

eleven
  • 6,779
  • 2
  • 32
  • 52