People , I have an async task which downloads some news items using a webservice . Here is the psuedo for that .
I have an operation that i perform in an asynctask . It downloads some news from a webservice .
AsyncTask
{
AsyncTask(Context context){}
doInBackground()
{
// download some news
..
..
return List<News>
}
onpostExecute(List <News>)
{
is the activity around ? if yes then
//find the list using context ,and populate it with news
}
}
My question is that , in midst of operation if the device is oriented , we will have a new AsyncTask . Now the old one already in progress has an internal List .
Would that be garbage collected ? . I think it wont . I smell the concept of weakreferences being applied on this situation , but I can't trust my nose here .
Also by weakreferences , I may know inside onPostExecute that the activity that spawned this Async is no longer around . But . I still believe I am missing a lot .
Or is this nothing I should worry about and the List would automatically be garbage collected once the asynctask finishes ?