codepath / codepath/android_guides
Do create View passing Activity as Context cause memory leak?
Open
- Dominant language
- No language data
- Stars
- 28.3k
- Forks
- 6.2k
- PR merge metrics
- No merged PRs in 30d
Description
```
public class MainActivity extends Activity {
private TextView textView;
protected void onCreate(Bundle savedInstanceState) {
textView = new TextView(this);
textView.setText("some text");
setContentView(textView);
}
}
```
We have two objects: one instance of `MainActivity` and one instance of `TextView` and both of them have reference to each other. So basically it will cause the memory leak. Am I right?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.