开发者

how to clear the reference of AsyncTask

in my app i have stored some images in drawable and i am showing those images in custom list view. When the activity gets opened and closed, the images are been allocated. When i do this continuously for around 12 times my app get crashed and it said because of memory out of image exception.

Then going through some others question in stack over flow i cleared the memory by clearing the recycle. But still the same error gets continued. Some others suggested that this may be due to not giving finish() in the end of the activity. I have tried that too but the same error gets continued. Then i tried clearing the image views too.

But after all this the number of times i am running the app get increased but the same error gets continued and it says that because of OutOfMemoryError. I dont know what to do here

Now my doubt is, i am calling this activity through an async task. Though the activity gets finished, the async task used to create an reference of the class. So i fear that because of this the app is getting crashed.

If my doubt is right, please t开发者_Python百科ell me how to check whether the reference of asyn task exists or not even after finishing the activity. If it is there how to clear it,

please help me friends.....


The object of Async task will be garbage collected if Asynctask is done and you're no longer holding a reference to it. I doubt it's the reason unless you're holding a list of Asynctask objects. If you're worried about it, then once you get the data from the Asynctask, set the reference to it to null.

My guess is you're just running out of memory from the images. Image handling in Android can be difficult when working with a lot of them. This thread helped considerably when I was having this issue. Basically it says to lower the image quality so it takes less memory.

Strange out of memory issue while loading an image to a Bitmap object

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜