0

I am working on design of an android social application. this app look like telegram. it has two activity. on first activity, list of group is shown. when user clicked on a group, list of group message is shown on second activity. message can contain text,photo,video or sticker. I use a RecyclerView to show list of message.

sometimes when user is working on second activity, out of memory error is happened.

when a photo message must be shown, the bitmap of before photo message is recycled and set to null, then i show the new photo message on Imageview.

to show a sticker message, by using a library, the bitmap is created from sticker file, and shown on ImageView. the process of creating bitmap, get noticeable amount of memory. i asked about sticker problem in this post

when user is working on message list activity, memory diagram look like below image.

enter image description here

when the user reads its group messages and come back to first activity, the second activity is destroyed but memory of second activity is not freed. when the user clicks on another group, second activity started again and it use another part of free memory. repeating this action cause consuming more and more memory and finally end of application working because of "out of memory".

when the user closes the app,the memory is not freed. if the user opens the app again, free part of memory is used to show application. multiple opening of app cause out of memory.

what should i do? how to free heap memory when an activity is destroyed or the app is closed.

the size of images (50px * 90px) and stickers (20kb - 50kb) is small.

sorry if i am poor in English. i hope that someone can help me.

Community
  • 1
  • 1
Motahare Sehati
  • 149
  • 2
  • 9
  • size in KB doesn't matter. Only resolution matters. What is the resolution of stickers? – Vladyslav Matviienko Dec 04 '16 at 18:05
  • when i convert it to bitmap. width and height of bitmap is 512 * 512. i know that it help out of memory issue, but i dont know how to solve. i asked about it. can you answer me in this link http://stackoverflow.com/questions/40911650/out-of-memory-happened-on-showing-sticker-on-imageview – Motahare Sehati Dec 04 '16 at 18:17

0 Answers0