title: Holding context, activity or views as member of a class is bad performance?
body: <p>I have red somewhere that keeping views as members of an activity is bad performance, because each views is keeping a reference to its parent Context and it will fill up the heap. Is this true?</p>
  
  <p><strong>Imagine this activity:</strong></p>
  
  <pre><code>public class MyActivity extends FragmentActivity{
     private RelativeLayout mainLayout;
     private LineraLayout menuLayout;
     private FrameLayout tableLayout;
  
     private Button buttonOk;
     private Button buttonCancel;
  
     @Override
     protected void onCreate(Bundle bundle){
        super.onCreate(bundle);
  
        mainLayout = (RelativeLayout) findViewById(R.id.mainlayout);
        // And inflating other views
     }
  }
  </code></pre>
  
  <p>And what about <strong>adapters</strong>?</p>
  
  <pre><code>public class MyAdapter extends BaseAdapter{
  
     private MyActivity activity;
     private ArrayList&lt;MyObjects&gt; myObjects;   
  
     public MyAdapter (MyActivity activity, ArrayList&lt;MyObjects&gt; myObjects){
        this.activity = activity;
        this.myObjects = myObjects;
     }
  }
  </code></pre>
  
  <p>Is this bad performance? Is it bad to pass an activity as a parameter instead of a Context? What if I want to access public methods from the parent <code>MyActivity</code> class from the adapter?</p>
  
  <p><strong>Non-Activity class</strong></p>
  
  <pre><code>public MyDatabase{
     private Context context;
     private SQLiteDatabase db;
  
     public MyDatabase(Context context){
        this.context = context;
        this.db = new DatabaseHelper(context).getWritableDatabase();
     }
  
     public Object getData(int id){
        return db.query(params...);
     }
  
     public static class DatabseHelper extends SQLiteOpenHelper{
        public DatabaseHelper(Context context){
           super(context, "my_db", null, 1);
        }
     }
  }
  </code></pre>
  
  <p>Why people are saying that when a class constructor expects a <code>Context</code> as a parameter, you should pass <code>getApplicationContext()</code> instead of and Activity?</p>