Search text and image OutOfMemory Exception
<p>i implemented a search text for my list,</p>

<p>Every list row item includes a text and image that i downloaded from server.</p>

<p>i alsways keeps two list, one is the original List of text and images and other one is the sorted Lists of text and image...</p>

<p>if my list containes only 4 items, so my app works well, however if my list containes 20 items and every image is 1MB and i need to keep two lists listImagesOriginal , image_array inside adapter  ( = 40MB)  i recieve a OutOfMemory Exception.</p>

<p>how can i reduce the memory consuption that i will not recive a OutOfMemory Exception?</p>

<p>thanks alot</p>

<p>how can i reduce the</p>

<pre><code>private MyCustomAdapter adapter;

private List&lt;String&gt; text = new ArrayList&lt;String&gt;();
private List&lt;Bitmap&gt; listImages;



private List&lt;String&gt; textOriginal = new ArrayList&lt;String&gt;();
private List&lt;Bitmap&gt; listImagesOriginal =new ArrayList&lt;Bitmap&gt;();

adapter =new MyCustomAdapter(text,listImages);
         ListView.setAdapter(adapter);



searchText= (EditText) findViewById(R.id.profile_page_search);

         searchText.addTextChangedListener(new TextWatcher()
         {
             public void afterTextChanged(Editable s)
             {
                   // Abstract Method of TextWatcher Interface.
                 textlength = searchText.getText().length();
                 adapter.deleteAllForSearch();
                 for (int i = 0; i &lt; textOriginal.size(); i++)
                 {

                         if(textOriginal.get(i).contains(
                                 searchText.getText().toString().trim()))
                         {
                             adapter.addObjectForSearch(textOriginal.get(i), listImagesOriginal.get(i));
                         }

                 }
             }
             public void beforeTextChanged(CharSequence s,
                     int start, int count, int after)
             {
                 // Abstract Method of TextWatcher Interface.
             }
             public void onTextChanged(CharSequence s,
                     int start, int before, int count)
             {

              }
          });




class MyCustomAdapter extends BaseAdapter{
          public   List&lt;String&gt; text_array = new ArrayList&lt;String&gt;();
          public   List&lt;Bitmap&gt; image_array = new ArrayList&lt;Bitmap&gt;();


          public int getCount(){
               return text_array.size();
          }

          MyCustomAdapter(List&lt;String&gt; text, List&lt;Bitmap&gt;)
          {

           text_array = text;
           image_array = image;

          }

          public long getItemId(int position){
               return position;
          }
          public String getItem(int position){
               return null;
          }
          public View getView(final int position, View convertView, ViewGroup parent) {
               //my implementation
          }

public void addObjectForSearch(String text, Bitmap bitmap) {
                text_array.add(text);
                image_array.add(bitmap);


                notifyDataSetChanged();

          }
</code></pre>
