list.remove() not deallocate the memory?

I have difficulty in getting the list (list of std) to the end and read your data. when I remove all elements, the list is never empty and never goes out of the loop (as to leave the element but it is the memory address, hence when having access the first element of the list returns the memory address and not the element). how can I deallocate the memory address of the list?
while (!listaQ.empty())
{ for(it = listaQ.begin(); it!= listaQ.end(); it++)
{ if(d->at(it)<temp) {
{ temp= d->at(it);
u=it;
}
}
listaQ.remove(u);
}