title: how to resolve "java.lang.OutOfMemoryError: Failed to allocate a 996567422 byte allocation with 7088560 free bytes and 117MB until OOM" in android
body: <p>how to resolve "java.lang.OutOfMemoryError: Failed to allocate a 996567422 byte allocation with 7088560 free bytes and 117MB until OOM" in android.</p>
  
  <p>Because of large images size i am getting this problem,i added these two lines in manifest file</p>
  
  <p>android:hardwareAccelerated="false"  ,
          android:largeHeap="true"</p>
  
  <p>then also not working,how to resolve the OutOfMemoryError </p>
  
  <p>this is my logcat </p>
  
  <pre><code>04-05 12:01:43.287 11314-17193/info.sherpify.pavithracs.sherpifys E/art: Throwing OutOfMemoryError "Failed to allocate a 996567422 byte allocation with 7078106 free bytes and 117MB until OOM"
  04-05 12:01:43.289 11314-17193/info.sherpify.pavithracs.sherpifys E/AndroidRuntime: FATAL EXCEPTION: Thread-88543
                                                                                      Process: info.sherpify.pavithracs.sherpifys, PID: 11314
                                                                                      java.lang.OutOfMemoryError: Failed to allocate a 996567422 byte allocation with 7078106 free bytes and 117MB until OOM
                                                                                          at com.android.volley.toolbox.DiskBasedCache.streamToBytes(DiskBasedCache.java:316)
                                                                                          at com.android.volley.toolbox.DiskBasedCache.readString(DiskBasedCache.java:526)
                                                                                          at com.android.volley.toolbox.DiskBasedCache.readStringStringMap(DiskBasedCache.java:549)
                                                                                          at com.android.volley.toolbox.DiskBasedCache$CacheHeader.readHeader(DiskBasedCache.java:392)
                                                                                          at com.android.volley.toolbox.DiskBasedCache.initialize(DiskBasedCache.java:155)
                                                                                          at com.android.volley.CacheDispatcher.run(CacheDispatcher.java:85)
  </code></pre>
  
  <p>see the below coding i am setting the image to imageview by using picasso.</p>
  
  <pre><code>package info.sherpify.pavithracs.sherpifys.adapter;
  
  /**
   * Created by pavithracs on 11/1/17.
   */
  
  import android.support.v7.widget.RecyclerView;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  
  import com.squareup.picasso.Picasso;
  
  import java.util.List;
  
  import info.sherpify.pavithracs.sherpifys.R;
  import info.sherpify.pavithracs.sherpifys.model.Categorieslist;
  import info.sherpify.pavithracs.sherpifys.utilis.NetworkUtils;
  
  
  public class RecyclerViewAdapterSearch extends RecyclerView.Adapter&lt;RecyclerViewAdapterSearch.ViewHolder&gt; {
  
      private List&lt;Categorieslist&gt; items;
      private OnItemClickListener onItemClickListener;
  
      public RecyclerViewAdapterSearch(List&lt;Categorieslist&gt; items) {
          this.items = items;
      }
  
      public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
          this.onItemClickListener = onItemClickListener;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list_home_search, parent, false);
          return new ViewHolder(v);
      }
  
      @Override
      public void onBindViewHolder(ViewHolder holder, final int position) {
          Categorieslist item = items.get(position);
          Log.i("Items mentor",""+item);
  
          try {
  
  
              holder.textmentordesignation.setText(item.getFieldUserDesig());
              holder.textyearofexperience.setText(item.getFieldUserExp()+" Years");
              holder.textmentorname.setText(item.getFieldUserName());
              holder.textcurrentcompany.setText("Current: "+item.getFieldUserCurrentCompany());
              holder.textpreviouscompany.setText("Previous: "+item.getFieldUserPreviousCompany());
  
              Log.i("Field--",""+item.getFieldUserDesig());
              Log.i("Field--",""+item.getFieldUserName());
              Log.i("Field--",""+item.getFieldUserExp());
  
  
  
              holder.image.setImageBitmap(null);
              Picasso.with(holder.image.getContext()).load(NetworkUtils.BASE_IMAGE_URL_USER_PICS +item.getFieldUserProfilepic()).resize(50, 50).error(R.drawable.com_facebook_profile_picture_blank_portrait).into(holder.image);
  
             holder.itemView.setTag(item);
              holder.relativementor.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
                      onItemClickListener.onItemClick(v,items.get(position).getFieldUserId(),items.get(position).getFieldUserName(),items.get(position).getFieldUserDesig(),items.get(position).getFieldUserSummary(),items.get(position).getFieldUserProfilepic(),items.get(position).getFieldUserCurrentCompany(),items.get(position).getFieldMentorId());
                  }
              });
  
  
          } catch (NullPointerException e) {
              e.printStackTrace();
          }
  
  
      }
  
      @Override
      public int getItemCount() {
          return items.size();
      }
  
  
      protected static class ViewHolder extends RecyclerView.ViewHolder {
          public TextView textmentordesignation,textyearofexperience,textmentorname,textcurrentcompany,textpreviouscompany;
          public ImageView image;
          RelativeLayout relativementor;
  
          public ViewHolder(View itemView) {
              super(itemView);
              image = (ImageView) itemView.findViewById(R.id.image);
              textmentordesignation = (TextView) itemView.findViewById(R.id.textmentordesignation);
              textyearofexperience = (TextView) itemView.findViewById(R.id.textyearsofexperience);
              textmentorname = (TextView) itemView.findViewById(R.id.textmentorname);
              textcurrentcompany = (TextView) itemView.findViewById(R.id.textcurrentcompany);
              textpreviouscompany = (TextView) itemView.findViewById(R.id.textpreviouscompany);
              relativementor = (RelativeLayout) itemView.findViewById(R.id.relativementor);
  
          }
      }
  
      public interface OnItemClickListener {
          void onItemClick(View view, String viewModel, String cName, String uId, String catId,String catProfilepic,String currentcompany,String mentorid);
      }
  
  }
  </code></pre>