Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:58:49+00:00 2026-06-15T10:58:49+00:00

UPDATE : 10/12/2012 After making with images: WeakHashMap<Bitmap, WeakReference<Bitmap>> objReferenciaDebilBitmaps; Bitmap imagen = datossss.getImagen();

  • 0

UPDATE : 10/12/2012

After making with images:

 WeakHashMap<Bitmap, WeakReference<Bitmap>> objReferenciaDebilBitmaps;
 Bitmap imagen = datossss.getImagen();
 objreCReferencias.RegristrarReferenciaDebilBitmap(imagen, objReferenciaDebilBitmaps);

my class Creferencias

public class CReferencias {


public CReferencias(){

}

public void RegristrarReferenciaDebilBitmap(Bitmap img, WeakHashMap<Bitmap, WeakReference<Bitmap>> objReferenciaDebilBitmaps){
    WeakReference<Bitmap> objrererencia1 = new WeakReference<Bitmap>(img);
    objReferenciaDebilBitmaps.put(img, objrererencia1);

}

After using this every time I do I create an Image, I do not know if it’s the right way to use weak references to the bitmap,

but still gives me the problem sigiente

this is my logcat

  12-10 13:54:53.523: E/dalvikvm-heap(1211): Out of memory on a 2304016-byte allocation.
12-10 13:54:53.528: E/AndroidRuntime(1211): FATAL EXCEPTION: main
12-10 13:54:53.528: E/AndroidRuntime(1211): java.lang.OutOfMemoryError
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.graphics.Bitmap.nativeCreate(Native Method)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at dep.Agenda.CustomAdapterDetalleEventos.getView(CustomAdapterDetalleEventos.java:558)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.widget.AbsListView.obtainView(AbsListView.java:2201)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.widget.ListView.makeAndAddView(ListView.java:1774)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.widget.ListView.fillUp(ListView.java:705)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.widget.ListView.fillGap(ListView.java:645)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5263)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.widget.AbsListView$TwFlingRunnable.run(AbsListView.java:4156)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.os.Handler.handleCallback(Handler.java:605)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.os.Looper.loop(Looper.java:137)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at android.app.ActivityThread.main(ActivityThread.java:4507)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at java.lang.reflect.Method.invokeNative(Native Method)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at java.lang.reflect.Method.invoke(Method.java:511)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
12-10 13:54:53.528: E/AndroidRuntime(1211):     at dalvik.system.NativeStart.main(Native Method)

this is lines my adapter

    public View getView(final int position,  View convertView, ViewGroup parent){
        View vistaFila =null;

     final  ElementosLinea objelementos;//=null;

        //final ElementosLinea obj;
        //final View auxVistaFila=null;


     LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if (convertView == null) {
             //  LayoutInflater inflator = context.getLayoutInflater();


            //LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            vistaFila = vi.inflate(R.layout.ll_lineas_lista_detalle_evento_nueva, null);

            //AsignarElementos(vistaFila);

           objelementos = new ElementosLinea();
          AsignarElementos(vistaFila,objelementos);




         vistaFila.setTag(objelementos);
         objelementos.posicion= position;

        }else{
            //vistaFila = vi.inflate(R.layout.ll_lineas_lista_detalles_evento, null);
          vistaFila=convertView;
          objelementos=(ElementosLinea)convertView.getTag();
          objelementos.posicion= position;
       }

        DetalleEvento datossss = arrayDatos.get(position);

        if (datossss.getGusta()==0){

            objelementos.btnMegusta.setBackgroundResource(R.drawable.megustagris);
            objelementos.txtMegusta.setText("Me gusta");
        }else{
            objelementos.btnMegusta.setBackgroundResource(R.drawable.megustaazul);
            objelementos.txtMegusta.setText("No me gusta"); 
            }


      //llenamos la barra de progreso
    if (datossss.getTipo()==1){//SI ES UN VIDEO

        objelementos.txtTitulo.setText(datossss.getTituloPost());
        objelementos.txtAutor.setText(datossss.getAutor());
        objelementos.txtPost.setVisibility(View.INVISIBLE);

        if (datossss.getImagen()!=null){
            Bitmap imagen = datossss.getImagen();
            objreCReferencias.RegristrarReferenciaDebilBitmap(imagen, objReferenciaDebilBitmaps);
             int width = imagen.getWidth();
                int height = imagen.getHeight();
                int newWidth = activiadPricipal.getWindowManager().getDefaultDisplay().getWidth();
                int newHeight = newWidth-80;

                float scalarw=((float) newWidth) /width;
                float scalarh=((float) newHeight) /height;

            Matrix ma = new Matrix();
             ma.postScale(scalarw, scalarh);

             Bitmap res = Bitmap.createBitmap(imagen, 0, 0,
                  width, height, ma, true);
        objreCReferencias.RegristrarReferenciaDebilBitmap(res, objReferenciaDebilBitmaps); 
        objelementos.imgfotoVideo.setImageBitmap(res);
        //imagen.recycle();
        //res.recycle();
        objelementos.btnComentarios.setEnabled(true);
        objelementos.pgrprogreso.setVisibility(View.INVISIBLE);

        }else{


              int newWidth = activiadPricipal.getWindowManager().getDefaultDisplay().getWidth();
              int newHeight = newWidth-80;

              objelementos.imgfotoVideo.setImageBitmap(null);
              objelementos.imgfotoVideo.setMinimumHeight(newHeight);
              objelementos.imgfotoVideo.setMinimumWidth(newWidth);
              objelementos.pgrprogreso.setVisibility(View.VISIBLE);
        objelementos.btnComentarios.setEnabled(false);
        }
        objelementos.imgfotoVideo.setVisibility(View.VISIBLE);
        objelementos.btnVerVideo.setVisibility(View.VISIBLE);
        objelementos.txtFecha.setText(datossss.getFecha());
        objelementos.btnVerfoto.setVisibility(View.INVISIBLE);




    }else{  if (datossss.getTipo()==2){ //SI ES UN POST

        objelementos.txtTitulo.setText(datossss.getTituloPost());
        objelementos.txtAutor.setText(datossss.getAutor());
        objelementos.txtPost.setText(datossss.getTexto());
        objelementos.txtPost.setVisibility(View.VISIBLE);
        objelementos.imgfotoVideo.setVisibility(View.INVISIBLE);
        objelementos.imgfotoVideo.setImageBitmap(null);
        objelementos.btnVerVideo.setVisibility(View.INVISIBLE);
        objelementos.txtFecha.setText(datossss.getFecha());
        objelementos.btnVerfoto.setVisibility(View.INVISIBLE);
        objelementos.btnComentarios.setEnabled(true);

        objelementos.imgfotoVideo.setMinimumHeight(0);
          objelementos.imgfotoVideo.setMinimumWidth(0);

          objelementos.pgrprogreso.setVisibility(View.INVISIBLE);
        //rtlCuerpo.set






    }else{//SI ES UNA FOTO

        objelementos.txtTitulo.setText(datossss.getTituloPost());
        objelementos.txtAutor.setText(datossss.getAutor());
        objelementos.imgfotoVideo.setVisibility(View.VISIBLE);
        objelementos.btnVerfoto.setVisibility(View.VISIBLE);


        if (datossss.getImagen()!=null){
        Bitmap imagen = datossss.getImagen();
         objreCReferencias.RegristrarReferenciaDebilBitmap(imagen, objReferenciaDebilBitmaps); 
         int width = imagen.getWidth();
            int height = imagen.getHeight();
            int newWidth = activiadPricipal.getWindowManager().getDefaultDisplay().getWidth();
            int newHeight = newWidth-80;

            float scalarw=((float) newWidth) /width;
            float scalarh=((float) newHeight) /height;

        Matrix ma = new Matrix();
         ma.postScale(scalarw, scalarh);

         Bitmap res = Bitmap.createBitmap(imagen, 0, 0,
              width, height, ma, true);

         objreCReferencias.RegristrarReferenciaDebilBitmap(res, objReferenciaDebilBitmaps);     
        objelementos.imgfotoVideo.setImageBitmap(res);
        //imagen.recycle();
        //res.recycle();
        objelementos.btnComentarios.setEnabled(true);
        objelementos.pgrprogreso.setVisibility(View.INVISIBLE);
        }else{
              int newWidth = activiadPricipal.getWindowManager().getDefaultDisplay().getWidth();
              int newHeight = newWidth-80;

              objelementos.imgfotoVideo.setImageBitmap(null);
              objelementos.imgfotoVideo.setMinimumHeight(newHeight);
              objelementos.imgfotoVideo.setMinimumWidth(newWidth);


            objelementos.btnComentarios.setEnabled(false);
            objelementos.pgrprogreso.setVisibility(View.VISIBLE);
        }
        objelementos.txtPost.setVisibility(View.INVISIBLE);
        objelementos.btnVerVideo.setVisibility(View.INVISIBLE);
        objelementos.txtFecha.setText(datossss.getFecha());



    }



    }

    if (datossss.getImagenAvatar()!=null){
         objelementos.imgAvatar.setImageBitmap(datossss.getImagenAvatar());
    }else{
         objelementos.imgAvatar.setImageResource(R.drawable.avatarpredeterminado);
    }


     objelementos.txtTitulo.setText(datossss.getTituloPost());



    return vistaFila;



      }

the objelementos equivalent viewholder

that’s what I’m doing wrong? I might say, as is the proper way to use weak references for all images and are deleted when I do not need?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:58:50+00:00Added an answer on June 15, 2026 at 10:58 am

    If you are using bitmaps in your app, don’t forget to call bmp.recycle() as GC in android cannot recycle bitmaps (for < Android v4.0, From 4.0 onwards, bitmaps are part of dvm). Also see my answer on same problem. I have addressed many answers, it will definitely solve your problem.
    bitmap size exceeds Vm budget error android

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After the July 31, 2012 update of Chrome to 21.0.1180.60, my app built with
I have a few sites using geoPlugin and after Microsoft's IE Update on 9/24/2012
After installing the Java for OS X 2012-006 update, the Java Preferences app, for
I am using Visual studio 2011 beta with the april 2012 update installed .I
Platform: ASP.NET 4.0, MVC 4 RC, VS 2012 Update: I've answer my question, myself.
How to update Active directory from Ax 2012 ? for example, how to update
I have this query update user_remember_me set when='2012-07-06 05:44:27', hash='c8e9d2c0dd156b5c68d0b048e5daa948e6b8fac7' where user = '21';
I`m trying to update time in datetime field as UPDATE table_name SET col_name=to_DATE('04/02/2012 00:12:00','MM/DD/YYYY
I'm using AWS SDK for .NET to upload several images. Before making the PutObjectRequest,
After a simple apt-get update on ubuntu 10.11, I lost the svn polling possibility.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.