What to do when button assigned to a static variable in order to avoid memory leak
<p>I read the link at <a href="http://developer.android.com/resources/articles/avoiding-memory-leaks.html" rel="nofollow">http://developer.android.com/resources/articles/avoiding-memory-leaks.html</a>
and need to know what should be done if I create a button </p>

<p>Button button = new Button(this) in an activity </p>

<p>and assign the button to a static variable "sButton"</p>

<p>sButton = button</p>

<p>What should be done in the onDestroy() method of the activity to avoid memory leakage.Will assigning sButton=null do the job sufficiently?Or do we have to call some other methods on sButton.</p>

<p>Suppose we do the same thing as above but instead of button we save the activity class itself or activity context to a static variable,what should be done so that to delete all reference of the activity so that the activity could be destroyed properly incase of memory shortage.</p>
