I wanted to ask this question, which was asked several times earlier. Sorry if I repeat again, but I donโt understand that this is the best solution here.
Question: "How to clear the bitmap ImageView resource after using it so that we do not have references to it in memory?".
Here is an example:
- Screen 1 redirects to Screen 2
- Screen 2 contains the A control (large photo preview)
- Control A contains ImageView B
- ImageView B installs when control A starts
Everything works great for the first time. As soon as the A control is completed, I am redirected from screen 2 to screen 1. At this point, all the links for the A or ImageView B or Bitmap control must be dead. THEY ARE NOT!!!
I tried all kinds of solutions, including bitmap.recycle (), adding finalize () to Control A, System.gs () and nullifying the control in different places like onStop () and onDestroy (), and everything else on screen 2 nothing works!
The problem is that Iโm viewing the screen again a second time, so Iโm moving from screen 1 to screen 2 (i.e., again creating a preview of the photo). I am getting a memory exception. As far as I understand, the link to the previous bitmap is not cleared.
How can I kill him before redirecting back to screen 1?
One thing I noticed. If I reduce the size of the photo, say, crop or reduce the size of the image, everything will go smoothly, several times ... before I get the same problem. So basically it will take a little longer to fill out.
I would really appreciate a solution to this problem, as it is important.