Reputation: 3
I'm develoving an Android App, where have two activities that use a RecyclerView with a customized layout that contains images. To load the images, I have:
ImageView imgView = (ImageView)itemView.findViewById(R.id.imgView);
Bitmap bitmap1 = BitmapFactory.decodeResource(context.getResources(), R.drawable.led);
imgView.setImageBitmap(bitmap1);
I thought that at the onDestroy() method of the activity, if the images were loaded as Bitmaps the GC would be able to free some space, however this is not happening and the usage of RAM memory increases until the app crashes for an OOM error.
Could anyone help me to figure out what's wrong?
Upvotes: 0
Views: 181
Reputation: 3887
You don't need a bitmap for only displaying drawable resource to the ImageView. You can directly do that!
imgView.setImageResource(R.drawable.led);
Upvotes: 2