How to clean AsyncTasks from memory after running?

0

I am developing a commercial APP, in this case I need to load all the clients of the establishment, so I make a request requesting each client, since I need to send the ID of this in the request URL, so far so good, the problem is that when I do example, 150 client request works, this results in 150 new AsyncTask().execute(); .

In a next scenario, I need to request 700 clients, that is, 700% with%, so I need to clear those that have already been completed, already tried new AsyncTask().execute() and I did not succeed.

I have a new AsyncTask().executeOnExecutor(Executors.newSingleThreadExecutor()); that contains the client IDs I need to 'get', (I have an EndPoint that returns me the Client IDs I can 'get'), as parameter, then goes the client ID at the end remove position 0 and do a check if client still exits without synchronizing.
Code of ArrayList<Integer> :

clientesAguardandoSincronizar.remove(0);
mAsyncCliente = null;
if(clientesAguardandoSincronizar.size()>0){
     //Executa novamente o Async de Clientes para trazer um a um.
     mAsyncCliente = new AsyncCliente(context).execute();
}else{
     //Executa proxima AsyncTask.
}
    
asked by anonymous 27.09.2017 / 22:27

1 answer

0

If someone has this problem, this happened to me because I was using Volley and every request he generated a Thread and left it in memory. I used HTTPRequest and made all requests from the same AsyncTask, and it worked fine.

    
29.09.2017 / 17:21